From nobody Fri Oct 2 07:47:19 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B58882FE575 for ; Tue, 4 Aug 2026 06:15:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785824131; cv=none; b=YSKJDIy91HWFn9SvF6miNkpgls8qgeizNp4BPoPGzbPMNxIV0j8lUi9wXkJuoUE9ALbFEwxd5Idyvof7qGe/H1pZgI6XNZAtL4a/u27X5bLruiOXVjId5UpsAFMceZ09kGKEUEmlfbLt3JE9cCZfqav0kCbaduSCZbT48uXOEiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785824131; c=relaxed/simple; bh=uQwtrfbhZNwThZzF8Ewv1t0g/387N7/YSVdmIR3Nli8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=h+VxSGEHSytGjiug32Crgd0z7jjc1Ot9MmSuIsBjfnIqUfToWDZN01ZP5zONFvI+ihsVe5Zxw36DXB0lnKLf5LuJgmtFH+upZy7r1lrN8NvP55/GwFHcQakzRE6yDMu/2iujaEL/RG2QQFupqXzd2lbIBrJh5SHR/ci5t7x7pM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: dec6b2548fcb11f1aa26b74ffac11d73-20260804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:8e921f41-d819-469e-b44a-0ef87e57921f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:5ab17f536f7e7a73eb135b01826dfda3,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|865|898,TC:nil,Content:0|15|50,E DM:-3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA :0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: dec6b2548fcb11f1aa26b74ffac11d73-20260804 X-User: zenghongling@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1982516692; Tue, 04 Aug 2026 14:15:20 +0800 From: Hongling Zeng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com Cc: linux-kernel@vger.kernel.org, zhongling0719@126.com, Hongling Zeng , Zhan Xusheng Subject: [PATCH v2] sched/numa: avoid doubling scan period for remote private faults Date: Tue, 4 Aug 2026 14:15:15 +0800 Message-Id: <20260804061515.640924-1-zenghongling@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" update_task_scan_period() currently uses local + shared to determine whether there were any relevant memory faults. This incorrectly treats a workload with only remote private faults as having no faults: local =3D 0 shared =3D 0 remote > 0 As a result, the NUMA scan period is unconditionally doubled. Use local + remote for the no-fault check so that remote private faults continue through the locality-ratio calculation. This does not necessarily make the scan period shorter. For a pure private workload, ps_ratio reaches NUMA_PERIOD_SLOTS and the ratio logic still increases the scan period. However, it avoids the unconditional doubling and lets the normal policy determine the adjustment. Also fix the comments for ps_ratio and lr_ratio, which described the opposite ratios. Suggested-by: Zhan Xusheng Signed-off-by: Hongling Zeng --- Changes from v1: - Corrected commit message to remove incorrect "speed up" claim - Changed patch title to accurately reflect the behavioral change - Removed stale comment in lr_ratio branch about shared memory - Added scan period comparison for clarity --- kernel/sched/fair.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 37001c63452e..78f8dc4cf5ea 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3505,9 +3505,13 @@ static void update_task_scan_period(struct task_stru= ct *p, * completely idle or all activity is in areas that are not of interest * to automatic numa balancing. Related to that, if there were failed * migration then it implies we are migrating too quickly or the local - * node is overloaded. In either case, scan slower + * node is overloaded. In either case, scan slower. + * + * Slow down if there are no actual memory faults (local + remote =3D=3D = 0), + * or if previous migrations failed. Otherwise, use the locality ratios + * to decide whether the scan rate should be adjusted. */ - if (local + shared =3D=3D 0 || p->numa_faults_locality[2]) { + if (local + remote =3D=3D 0 || p->numa_faults_locality[2]) { p->numa_scan_period =3D min(p->numa_scan_period_max, p->numa_scan_period << 1); =20 @@ -3529,8 +3533,8 @@ static void update_task_scan_period(struct task_struc= t *p, =20 if (ps_ratio >=3D NUMA_PERIOD_THRESHOLD) { /* - * Most memory accesses are local. There is no need to - * do fast NUMA scanning, since memory is already local. + * Most memory accesses are private. Slow down NUMA scanning + * since there is little shared memory to rebalance. */ int slot =3D ps_ratio - NUMA_PERIOD_THRESHOLD; if (!slot) @@ -3538,9 +3542,8 @@ static void update_task_scan_period(struct task_struc= t *p, diff =3D slot * period_slot; } else if (lr_ratio >=3D NUMA_PERIOD_THRESHOLD) { /* - * Most memory accesses are shared with other tasks. - * There is no point in continuing fast NUMA scanning, - * since other tasks may just move the memory elsewhere. + * Most memory accesses are local. There is no need to + * do fast NUMA scanning, since memory is already local. */ int slot =3D lr_ratio - NUMA_PERIOD_THRESHOLD; if (!slot) --=20 2.25.1