Re: [GIT PULL] scheduler updates for v5.18

From: Ingo Molnar
Date: Tue Mar 22 2022 - 03:48:42 EST



* Ingo Molnar <mingo@xxxxxxxxxx> wrote:

>
> * Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > On Mon, Mar 21, 2022 at 6:13 AM Qian Cai <quic_qiancai@xxxxxxxxxxx> wrote:
> > >
> > > On Mon, Mar 21, 2022 at 11:54:09AM +0100, Ingo Molnar wrote:
> > > > Huang Ying (3):
> > > > sched/numa-balancing: Move some document to make it consistent with the code
> > > > sched/numa: Fix NUMA topology for systems with CPU-less nodes
> > > > sched/numa: Avoid migrating task to CPU-less node
> > >
> > > Linus, I don't think you want to merge this as-is. This will introduce a
> > > kernel crash on arm64 NUMA as mentioned in this thread,
> >
> > Ok, dropped from my queue. Thanks,
>
> I've reverted the broken commit & will send another pull request after
> some testing. Sorry about that!

Ended up using the fix below instead - it's tested already on the affected
system.

Thanks,

Ingo

=================>
From: "Huang, Ying" <ying.huang@xxxxxxxxx>
Date: Tue, 22 Mar 2022 08:39:22 +0100
Subject: [PATCH] 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 <quic_qiancai@xxxxxxxxxxx>
Tested-by: Qian Cai <quic_qiancai@xxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

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;