]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/sched-debug-initialize-sd_sysctl_cpus-if-config_cpum.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / sched-debug-initialize-sd_sysctl_cpus-if-config_cpum.patch
1 From 58bbfbca388e97b886247d17f2f5c3c98adc7776 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 6383aa6a60ca..141ea9ff210e 100644
42 --- a/kernel/sched/debug.c
43 +++ b/kernel/sched/debug.c
44 @@ -315,6 +315,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 @@ -344,7 +345,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