/[packages]/updates/8/kernel/current/SOURCES/mips-smp-fill-in-sibling-and-core-maps-earlier.patch
ViewVC logotype

Contents of /updates/8/kernel/current/SOURCES/mips-smp-fill-in-sibling-and-core-maps-earlier.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1795002 - (show annotations) (download)
Wed Mar 16 20:40:50 2022 UTC (2 years, 1 month ago) by tmb
File size: 4383 byte(s)
add current -stable queue
1 From d5d5d0c3125cbb6edd6fdf712108af74827b7f59 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Sat, 12 Feb 2022 22:21:11 +0000
4 Subject: MIPS: smp: fill in sibling and core maps earlier
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Alexander Lobakin <alobakin@pm.me>
10
11 [ Upstream commit f2703def339c793674010cc9f01bfe4980231808 ]
12
13 After enabling CONFIG_SCHED_CORE (landed during 5.14 cycle),
14 2-core 2-thread-per-core interAptiv (CPS-driven) started emitting
15 the following:
16
17 [ 0.025698] CPU1 revision is: 0001a120 (MIPS interAptiv (multi))
18 [ 0.048183] ------------[ cut here ]------------
19 [ 0.048187] WARNING: CPU: 1 PID: 0 at kernel/sched/core.c:6025 sched_core_cpu_starting+0x198/0x240
20 [ 0.048220] Modules linked in:
21 [ 0.048233] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.17.0-rc3+ #35 b7b319f24073fd9a3c2aa7ad15fb7993eec0b26f
22 [ 0.048247] Stack : 817f0000 00000004 327804c8 810eb050 00000000 00000004 00000000 c314fdd1
23 [ 0.048278] 830cbd64 819c0000 81800000 817f0000 83070bf4 00000001 830cbd08 00000000
24 [ 0.048307] 00000000 00000000 815fcbc4 00000000 00000000 00000000 00000000 00000000
25 [ 0.048334] 00000000 00000000 00000000 00000000 817f0000 00000000 00000000 817f6f34
26 [ 0.048361] 817f0000 818a3c00 817f0000 00000004 00000000 00000000 4dc33260 0018c933
27 [ 0.048389] ...
28 [ 0.048396] Call Trace:
29 [ 0.048399] [<8105a7bc>] show_stack+0x3c/0x140
30 [ 0.048424] [<8131c2a0>] dump_stack_lvl+0x60/0x80
31 [ 0.048440] [<8108b5c0>] __warn+0xc0/0xf4
32 [ 0.048454] [<8108b658>] warn_slowpath_fmt+0x64/0x10c
33 [ 0.048467] [<810bd418>] sched_core_cpu_starting+0x198/0x240
34 [ 0.048483] [<810c6514>] sched_cpu_starting+0x14/0x80
35 [ 0.048497] [<8108c0f8>] cpuhp_invoke_callback_range+0x78/0x140
36 [ 0.048510] [<8108d914>] notify_cpu_starting+0x94/0x140
37 [ 0.048523] [<8106593c>] start_secondary+0xbc/0x280
38 [ 0.048539]
39 [ 0.048543] ---[ end trace 0000000000000000 ]---
40 [ 0.048636] Synchronize counters for CPU 1: done.
41
42 ...for each but CPU 0/boot.
43 Basic debug printks right before the mentioned line say:
44
45 [ 0.048170] CPU: 1, smt_mask:
46
47 So smt_mask, which is sibling mask obviously, is empty when entering
48 the function.
49 This is critical, as sched_core_cpu_starting() calculates
50 core-scheduling parameters only once per CPU start, and it's crucial
51 to have all the parameters filled in at that moment (at least it
52 uses cpu_smt_mask() which in fact is `&cpu_sibling_map[cpu]` on
53 MIPS).
54
55 A bit of debugging led me to that set_cpu_sibling_map() performing
56 the actual map calculation, was being invocated after
57 notify_cpu_start(), and exactly the latter function starts CPU HP
58 callback round (sched_core_cpu_starting() is basically a CPU HP
59 callback).
60 While the flow is same on ARM64 (maps after the notifier, although
61 before calling set_cpu_online()), x86 started calculating sibling
62 maps earlier than starting the CPU HP callbacks in Linux 4.14 (see
63 [0] for the reference). Neither me nor my brief tests couldn't find
64 any potential caveats in calculating the maps right after performing
65 delay calibration, but the WARN splat is now gone.
66 The very same debug prints now yield exactly what I expected from
67 them:
68
69 [ 0.048433] CPU: 1, smt_mask: 0-1
70
71 [0] https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?id=76ce7cfe35ef
72
73 Signed-off-by: Alexander Lobakin <alobakin@pm.me>
74 Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
75 Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
76 Signed-off-by: Sasha Levin <sashal@kernel.org>
77 ---
78 arch/mips/kernel/smp.c | 6 +++---
79 1 file changed, 3 insertions(+), 3 deletions(-)
80
81 diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
82 index d542fb7af3ba..1986d1309410 100644
83 --- a/arch/mips/kernel/smp.c
84 +++ b/arch/mips/kernel/smp.c
85 @@ -351,6 +351,9 @@ asmlinkage void start_secondary(void)
86 cpu = smp_processor_id();
87 cpu_data[cpu].udelay_val = loops_per_jiffy;
88
89 + set_cpu_sibling_map(cpu);
90 + set_cpu_core_map(cpu);
91 +
92 cpumask_set_cpu(cpu, &cpu_coherent_mask);
93 notify_cpu_starting(cpu);
94
95 @@ -362,9 +365,6 @@ asmlinkage void start_secondary(void)
96 /* The CPU is running and counters synchronised, now mark it online */
97 set_cpu_online(cpu, true);
98
99 - set_cpu_sibling_map(cpu);
100 - set_cpu_core_map(cpu);
101 -
102 calculate_cpu_foreign_map();
103
104 /*
105 --
106 2.34.1
107

  ViewVC Help
Powered by ViewVC 1.1.30