Commit 9cec77f2 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Zheng Zengkai
Browse files

sched: Fix Core-wide rq->lock for uninitialized CPUs

mainline inclusion
from mainline-v5.14
commit 3c474b32
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5OOWG
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3c474b3239f12fe0b00d7e82481f36a1f31e79ab



--------------------------------------------------------------------------

Eugene tripped over the case where rq_lock(), as called in a
for_each_possible_cpu() loop came apart because rq->core hadn't been
setup yet.

This is a somewhat unusual, but valid case.

Rework things such that rq->core is initialized to point at itself. IOW
initialize each CPU as a single threaded Core. CPU online will then join
the new CPU (thread) to an existing Core where needed.

For completeness sake, have CPU offline fully undo the state so as to
not presume the topology will match the next time it comes online.

Fixes: 9edeaea1 ("sched: Core-wide rq->lock")
Reported-by: default avatarEugene Syromiatnikov <esyr@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarJosh Don <joshdon@google.com>
Tested-by: default avatarEugene Syromiatnikov <esyr@redhat.com>
Link: https://lkml.kernel.org/r/YR473ZGeKqMs6kw+@hirez.programming.kicks-ass.net


Conflicts:
	kernel/sched/core.c
	[Bugfix ed3cd45f("Merge tag 'v5.11' into sched/core,
	 to pick up fixes & refresh the branch") is not applied.]
Signed-off-by: default avatarLin Shengwang <linshengwang1@huawei.com>
Reviewed-by: default avatarlihua <hucool.lihua@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 70a9abf5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment