linux/kernel/sched
Oleg Nesterov 257bf89d84 sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU
housekeeping_setup() checks cpumask_intersects(present, online) to ensure
that the kernel will have at least one housekeeping CPU after smp_init(),
but this doesn't work if the maxcpus= kernel parameter limits the number of
processors available after bootup.

For example, a kernel with "maxcpus=2 nohz_full=0-2" parameters crashes at
boot time on a virtual machine with 4 CPUs.

Change housekeeping_setup() to use cpumask_first_and() and check that the
returned CPU number is valid and less than setup_max_cpus.

Another corner case is "nohz_full=0" on a machine with a single CPU or with
the maxcpus=1 kernel argument. In this case non_housekeeping_mask is empty
and tick_nohz_full_setup() makes no sense. And indeed, the kernel hits the
WARN_ON(tick_nohz_full_running) in tick_sched_do_timer().

And how should the kernel interpret the "nohz_full=" parameter? It should
be silently ignored, but currently cpulist_parse() happily returns the
empty cpumask and this leads to the same problem.

Change housekeeping_setup() to check cpumask_empty(non_housekeeping_mask)
and do nothing in this case.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20240413141746.GA10008@redhat.com
2024-04-28 10:08:21 +02:00
..
autogroup.c
autogroup.h
build_policy.c
build_utility.c
clock.c
completion.c
core.c RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
core_sched.c
cpuacct.c
cpudeadline.c
cpudeadline.h
cpufreq.c
cpufreq_schedutil.c sched/fair: Fix frequency selection for non-invariant case 2024-01-16 10:41:25 +01:00
cpupri.c
cpupri.h
cputime.c
deadline.c sched/deadline: Introduce deadline servers 2023-11-15 09:57:51 +01:00
debug.c sched/fair: Simplify util_est 2023-12-23 15:59:58 +01:00
fair.c sched/eevdf: Prevent vlag from going out of bounds in reweight_eevdf() 2024-04-22 13:01:27 +02:00
features.h sched/fair: Remove SCHED_FEAT(UTIL_EST_FASTUP, true) 2023-12-23 15:59:56 +01:00
idle.c Core x86 changes for v6.9: 2024-03-11 19:53:15 -07:00
isolation.c sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU 2024-04-28 10:08:21 +02:00
loadavg.c
Makefile
membarrier.c RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
pelt.c
pelt.h sched/fair: Simplify util_est 2023-12-23 15:59:58 +01:00
psi.c
rt.c sched: Unify runtime accounting across classes 2023-11-15 09:57:48 +01:00
sched-pelt.h
sched.h sched: Add missing memory barrier in switch_mm_cid 2024-04-16 13:59:45 +02:00
smp.h
stats.c
stats.h
stop_task.c sched: Unify runtime accounting across classes 2023-11-15 09:57:48 +01:00
swait.c
topology.c sched/topology: Rename SD_SHARE_PKG_RESOURCES to SD_SHARE_LLC 2024-02-28 15:43:17 +01:00
wait.c
wait_bit.c