Debian Codegraph @

vmtest/patches/sched-work-around-mystery-QEMU-hang.patch

raw
1 From 55628334c7c73c8b948d7d97be0e79b61b28cd11 Mon Sep 17 00:00:00 2001
2 Message-ID: <55628334c7c73c8b948d7d97be0e79b61b28cd11.1699049719.git.osandov@fb.com>
3 From: Omar Sandoval <[email protected]>
4 Date: Fri, 3 Nov 2023 14:50:46 -0700
5 Subject: [PATCH] sched: work around mystery QEMU hang
6
7 Before commit 2558aacff858 ("sched/hotplug: Ensure only per-cpu kthreads
8 run during hotplug") (in v5.11), GCC inlined the call to
9 raw_spin_unlock_irq() after __balance_callbacks() in __schedule(). That
10 change incidentally turned it into an uninlined function call. For some
11 reason, this causes the kernel to hang while calibrating loops_per_jiffy
12 for secondary CPUs, but only under QEMU full system emulation, not KVM.
13
14 Commit 5cb9eaa3d274 ("sched: Wrap rq::lock access") (in v5.14) added
15 some wrappers that essentially turned the call to raw_spin_unlock_irq()
16 into a (still not inlined by GCC) call to raw_spin_unlock() followed by
17 local_irq_enable(). This mysteriously gets rid of the hang.
18
19 This feels like a QEMU bug, but since it only affects EOL kernels, let's
20 just work around it.
21
22 See osandov/drgn#365.
23
24 Signed-off-by: Omar Sandoval <[email protected]>
25 ---
26 kernel/sched/core.c | 3 ++-
27 1 file changed, 2 insertions(+), 1 deletion(-)
28
29 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
30 index 4ca80df205ce..4901f47e84d8 100644
31 --- a/kernel/sched/core.c
32 +++ b/kernel/sched/core.c
33 @@ -5150,7 +5150,8 @@ static void __sched notrace __schedule(bool preempt)
34
35 rq_unpin_lock(rq, &rf);
36 __balance_callbacks(rq);
37 - raw_spin_unlock_irq(&rq->lock);
38 + raw_spin_unlock(&rq->lock);
39 + local_irq_enable();
40 }
41 }
42
43 --
44 2.41.0
45