Skip to content

Commit 9219565

Browse files
npigginIngo Molnar
authored andcommitted
sched/isolation: Require a present CPU in housekeeping mask
During housekeeping mask setup, currently a possible CPU is required. That does not guarantee the CPU would be available at boot time, so check to ensure that at least one present CPU is in the mask. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J . Wysocki <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9ca12ac commit 9219565

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

kernel/sched/isolation.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void __init housekeeping_init(void)
6565
static int __init housekeeping_setup(char *str, enum hk_flags flags)
6666
{
6767
cpumask_var_t non_housekeeping_mask;
68+
cpumask_var_t tmp;
6869
int err;
6970

7071
alloc_bootmem_cpumask_var(&non_housekeeping_mask);
@@ -75,25 +76,32 @@ static int __init housekeeping_setup(char *str, enum hk_flags flags)
7576
return 0;
7677
}
7778

79+
alloc_bootmem_cpumask_var(&tmp);
7880
if (!housekeeping_flags) {
7981
alloc_bootmem_cpumask_var(&housekeeping_mask);
8082
cpumask_andnot(housekeeping_mask,
8183
cpu_possible_mask, non_housekeeping_mask);
82-
if (cpumask_empty(housekeeping_mask))
84+
85+
cpumask_andnot(tmp, cpu_present_mask, non_housekeeping_mask);
86+
if (cpumask_empty(tmp)) {
87+
pr_warn("Housekeeping: must include one present CPU, "
88+
"using boot CPU:%d\n", smp_processor_id());
8389
__cpumask_set_cpu(smp_processor_id(), housekeeping_mask);
90+
__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
91+
}
8492
} else {
85-
cpumask_var_t tmp;
86-
87-
alloc_bootmem_cpumask_var(&tmp);
93+
cpumask_andnot(tmp, cpu_present_mask, non_housekeeping_mask);
94+
if (cpumask_empty(tmp))
95+
__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
8896
cpumask_andnot(tmp, cpu_possible_mask, non_housekeeping_mask);
8997
if (!cpumask_equal(tmp, housekeeping_mask)) {
9098
pr_warn("Housekeeping: nohz_full= must match isolcpus=\n");
9199
free_bootmem_cpumask_var(tmp);
92100
free_bootmem_cpumask_var(non_housekeeping_mask);
93101
return 0;
94102
}
95-
free_bootmem_cpumask_var(tmp);
96103
}
104+
free_bootmem_cpumask_var(tmp);
97105

98106
if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_TICK)) {
99107
if (IS_ENABLED(CONFIG_NO_HZ_FULL)) {

0 commit comments

Comments
 (0)