From nobody Fri Oct 2 07:47:04 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 AD2892836F for ; Tue, 4 Aug 2026 03:07:42 +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=1785812866; cv=none; b=ajDNTS3b6YI8LDmrJ/9RpPUqbkfVkHPNYvXnLsMkHEiv3WtIeHVSwl1X8ZHimeddBC1ik43VIDaSrZ6NHyhkgeh6aoAkyfiFbJ262Tc3Tyz63dRXfnq3S3q2JvbZXVvENtsPhWIpZZFpcmc6RrxvTOR1asl94xLotd5QYSTI7f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785812866; c=relaxed/simple; bh=mK7g2/cNg9jJQ2gLifOekEdjHvumoX4l5YTlkHBRLHc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=SJRMt4EK9OwtZQkgzfzOCNyek1mPOeJDlQopf7PJxgIvxJ2zKDMkkyg21UvPZNQJaV9fY/JNyY+K2vb/qYIekfLd/1KqEwoqs4UKOudhrvq2YKak8jIqU3ude1S6XSJLVmW/rPxPM1rAeDWoiTXs1uN8ITdeyW92oN7w7rLV/cI= 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: a48059208fb111f1aa26b74ffac11d73-20260804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:e7866ae7-8970-4211-87fe-93973f147dc0,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:9b94261af2e5321e3d99d9c4b1c27782,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: a48059208fb111f1aa26b74ffac11d73-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 1727645814; Tue, 04 Aug 2026 11:07:35 +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 Subject: [PATCH] sched/numa: Fix scan period for remote private faults Date: Tue, 4 Aug 2026 11:07:31 +0800 Message-Id: <20260804030731.539809-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" The early return condition in update_task_scan_period() incorrectly slows down NUMA scanning for workloads with pure remote private memory accesses. Current condition: if (local + shared =3D=3D 0 || p->numa_faults_locality[2]) For a workload accessing only private memory on remote nodes: - shared =3D 0 (no shared accesses) - local =3D 0 (all accesses are remote) - Result: condition is TRUE, scan period doubles (slower) This is wrong because for remote private memory, we should continue to the ratio calculation which can speed up scanning to migrate the memory to the local node. The fix checks if there are actual faults (local + remote > 0) before slowing down the scan rate. If there are faults, we should continue to the ratio calculation logic to make an informed decision. Also update the comments for ps_ratio and lr_ratio checks which appear to be swapped - ps_ratio checks private/shared ratio not local accesses, and lr_ratio checks local/remote ratio not shared accesses. Signed-off-by: Hongling Zeng --- kernel/sched/fair.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 37001c63452e..1fafaeb8d645 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,8 +3542,9 @@ 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, + * Most memory accesses are local. There is no need to + * do fast NUMA scanning, since memory is already local. + * Also, shared memory may be moved by other tasks anyway, * since other tasks may just move the memory elsewhere. */ int slot =3D lr_ratio - NUMA_PERIOD_THRESHOLD; --=20 2.25.1