[PATCH] sched/numa: clear locality statistics on early return

Hongling Zeng <[email protected]> Tue, 4 Aug 2026 17:02:05 +0800
Newsgroups org.kernel.vger.stable,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
A non-zero migration-failure locality statistic causes
update_task_scan_period() to take the slow-scan path and return before
the locality statistics are cleared.

Consequently, the same migration failure can affect subsequent
scan-period updates and repeatedly select the slow-scan path until the
maximum scan period is reached.

Clear the locality statistics before returning from the slow-scan path,
matching the cleanup performed by the normal path. This allows later
scan-period updates to use fresh locality and migration statistics.

Fixes: f307cd1a32fa ("sched/numa: Slow scan rate if no NUMA hinting faults are being recorded")
Cc: [email protected]
Signed-off-by: Hongling Zeng <[email protected]>
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 78f8dc4cf5ea..676fe1c3356e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3518,6 +3518,8 @@ static void update_task_scan_period(struct task_struct *p,
 		p->mm->numa_next_scan = jiffies +
 			msecs_to_jiffies(p->numa_scan_period);
 
+		memset(p->numa_faults_locality, 0,
+			sizeof(p->numa_faults_locality));
 		return;
 	}
 
-- 
2.25.1