Skip to content

Commit 1ca4fa3

Browse files
Hidetoshi SetoIngo Molnar
authored andcommitted
sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK
register_sched_domain_sysctl() copies the cpu_possible_mask into sd_sysctl_cpus, but only if sd_sysctl_cpus hasn't already been allocated (ie, CONFIG_CPUMASK_OFFSTACK is set). However, when CONFIG_CPUMASK_OFFSTACK is not set, sd_sysctl_cpus is left uninitialized (all zeroes) and the kernel may fail to initialize sched_domain sysctl entries for all possible CPUs. This is visible to the user if the kernel is booted with maxcpus=n, or if ACPI tables have been modified to leave CPUs offline, and then checking for missing /proc/sys/kernel/sched_domain/cpu* entries. Fix this by separating the allocation and initialization, and adding a flag to initialize the possible CPU entries while system booting only. Tested-by: Syuuichirou Ishii <[email protected]> Tested-by: Tarumizu, Kohei <[email protected]> Signed-off-by: Hidetoshi Seto <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Masayoshi Mizuma <[email protected]> Acked-by: Joe Lawrence <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Masayoshi Mizuma <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 10a35e6 commit 1ca4fa3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/sched/debug.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ void register_sched_domain_sysctl(void)
315315
{
316316
static struct ctl_table *cpu_entries;
317317
static struct ctl_table **cpu_idx;
318+
static bool init_done = false;
318319
char buf[32];
319320
int i;
320321

@@ -344,7 +345,10 @@ void register_sched_domain_sysctl(void)
344345
if (!cpumask_available(sd_sysctl_cpus)) {
345346
if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
346347
return;
348+
}
347349

350+
if (!init_done) {
351+
init_done = true;
348352
/* init to possible to not have holes in @cpu_entries */
349353
cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
350354
}

0 commit comments

Comments
 (0)