From ab31c7fd2d37bc3580d9d712d5f2dfb69901fca9 Mon Sep 17 00:00:00 2001 From: "Huang, Ying" Date: Tue, 22 Mar 2022 08:39:22 +0100 Subject: sched/numa: Fix boot crash on arm64 systems Qian Cai reported a boot crash on arm64 systems, caused by: 0fb3978b0aac ("sched/numa: Fix NUMA topology for systems with CPU-less nodes") The bug is that node_state() must be supplied a valid node_states[] array index, but in task_numa_placement() the max_nid search can fail with NUMA_NO_NODE, which is not a valid index. Fix it by checking that max_nid is a valid index. [ mingo: Added changelog. ] Fixes: 0fb3978b0aac ("sched/numa: Fix NUMA topology for systems with CPU-less nodes") Reported-by: Qian Cai Tested-by: Qian Cai Cc: Peter Zijlstra Cc: Linus Torvalds Signed-off-by: "Huang, Ying" Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel') diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 89d21fda106c..ee0664c9d291 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2437,7 +2437,7 @@ static void task_numa_placement(struct task_struct *p) } /* Cannot migrate task to CPU-less node */ - if (!node_state(max_nid, N_CPU)) { + if (max_nid != NUMA_NO_NODE && !node_state(max_nid, N_CPU)) { int near_nid = max_nid; int distance, near_distance = INT_MAX; -- cgit v1.2.3-70-g09d2