]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.111/sched-debug-initialize-sd_sysctl_cpus-if-config_cpum.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / sched-debug-initialize-sd_sysctl_cpus-if-config_cpum.patch
CommitLineData
04fd09d4
SL
1From 31442c240166277f25747d0330584adb36e0e47e Mon Sep 17 00:00:00 2001
2From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
3Date: Tue, 29 Jan 2019 10:12:45 -0500
4Subject: sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK
5
6[ Upstream commit 1ca4fa3ab604734e38e2a3000c9abf788512ffa7 ]
7
8register_sched_domain_sysctl() copies the cpu_possible_mask into
9sd_sysctl_cpus, but only if sd_sysctl_cpus hasn't already been
10allocated (ie, CONFIG_CPUMASK_OFFSTACK is set). However, when
11CONFIG_CPUMASK_OFFSTACK is not set, sd_sysctl_cpus is left
12uninitialized (all zeroes) and the kernel may fail to initialize
13sched_domain sysctl entries for all possible CPUs.
14
15This is visible to the user if the kernel is booted with maxcpus=n, or
16if ACPI tables have been modified to leave CPUs offline, and then
17checking for missing /proc/sys/kernel/sched_domain/cpu* entries.
18
19Fix this by separating the allocation and initialization, and adding a
20flag to initialize the possible CPU entries while system booting only.
21
22Tested-by: Syuuichirou Ishii <ishii.shuuichir@jp.fujitsu.com>
23Tested-by: Tarumizu, Kohei <tarumizu.kohei@jp.fujitsu.com>
24Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
25Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
26Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
27Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
28Cc: Linus Torvalds <torvalds@linux-foundation.org>
29Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>
30Cc: Mike Galbraith <efault@gmx.de>
31Cc: Peter Zijlstra <peterz@infradead.org>
32Cc: Thomas Gleixner <tglx@linutronix.de>
33Link: https://lkml.kernel.org/r/20190129151245.5073-1-msys.mizuma@gmail.com
34Signed-off-by: Ingo Molnar <mingo@kernel.org>
35Signed-off-by: Sasha Levin <sashal@kernel.org>
36---
37 kernel/sched/debug.c | 4 ++++
38 1 file changed, 4 insertions(+)
39
40diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
41index 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--
642.19.1
65