]>
Commit | Line | Data |
---|---|---|
04fd09d4 SL |
1 | From 31442c240166277f25747d0330584adb36e0e47e Mon Sep 17 00:00:00 2001 |
2 | From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | |
3 | Date: Tue, 29 Jan 2019 10:12:45 -0500 | |
4 | Subject: sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK | |
5 | ||
6 | [ Upstream commit 1ca4fa3ab604734e38e2a3000c9abf788512ffa7 ] | |
7 | ||
8 | register_sched_domain_sysctl() copies the cpu_possible_mask into | |
9 | sd_sysctl_cpus, but only if sd_sysctl_cpus hasn't already been | |
10 | allocated (ie, CONFIG_CPUMASK_OFFSTACK is set). However, when | |
11 | CONFIG_CPUMASK_OFFSTACK is not set, sd_sysctl_cpus is left | |
12 | uninitialized (all zeroes) and the kernel may fail to initialize | |
13 | sched_domain sysctl entries for all possible CPUs. | |
14 | ||
15 | This is visible to the user if the kernel is booted with maxcpus=n, or | |
16 | if ACPI tables have been modified to leave CPUs offline, and then | |
17 | checking for missing /proc/sys/kernel/sched_domain/cpu* entries. | |
18 | ||
19 | Fix this by separating the allocation and initialization, and adding a | |
20 | flag to initialize the possible CPU entries while system booting only. | |
21 | ||
22 | Tested-by: Syuuichirou Ishii <ishii.shuuichir@jp.fujitsu.com> | |
23 | Tested-by: Tarumizu, Kohei <tarumizu.kohei@jp.fujitsu.com> | |
24 | Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | |
25 | Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> | |
26 | Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | |
27 | Acked-by: Joe Lawrence <joe.lawrence@redhat.com> | |
28 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
29 | Cc: Masayoshi Mizuma <msys.mizuma@gmail.com> | |
30 | Cc: Mike Galbraith <efault@gmx.de> | |
31 | Cc: Peter Zijlstra <peterz@infradead.org> | |
32 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
33 | Link: https://lkml.kernel.org/r/20190129151245.5073-1-msys.mizuma@gmail.com | |
34 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
35 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
36 | --- | |
37 | kernel/sched/debug.c | 4 ++++ | |
38 | 1 file changed, 4 insertions(+) | |
39 | ||
40 | diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c | |
41 | index 2f93e4a2d9f6..187c04a34ba1 100644 | |
42 | --- a/kernel/sched/debug.c | |
43 | +++ b/kernel/sched/debug.c | |
44 | @@ -339,6 +339,7 @@ void register_sched_domain_sysctl(void) | |
45 | { | |
46 | static struct ctl_table *cpu_entries; | |
47 | static struct ctl_table **cpu_idx; | |
48 | + static bool init_done = false; | |
49 | char buf[32]; | |
50 | int i; | |
51 | ||
52 | @@ -368,7 +369,10 @@ void register_sched_domain_sysctl(void) | |
53 | if (!cpumask_available(sd_sysctl_cpus)) { | |
54 | if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL)) | |
55 | return; | |
56 | + } | |
57 | ||
58 | + if (!init_done) { | |
59 | + init_done = true; | |
60 | /* init to possible to not have holes in @cpu_entries */ | |
61 | cpumask_copy(sd_sysctl_cpus, cpu_possible_mask); | |
62 | } | |
63 | -- | |
64 | 2.19.1 | |
65 |