Patch "sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sched-isolation-fix-boot-crash-when-maxcpus-first-ho.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 658b604b169318055c02a9dc3f4d343414e80f6b
Author: Oleg Nesterov <oleg@xxxxxxxxxx>
Date:   Sat Apr 13 16:17:46 2024 +0200

    sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU
    
    [ Upstream commit 257bf89d84121280904800acd25cc2c444c717ae ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Reviewed-by: Phil Auld <pauld@xxxxxxxxxx>
    Acked-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240413141746.GA10008@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 373d42c707bc5..82e2f7fc7c267 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -109,6 +109,7 @@ static void __init housekeeping_setup_type(enum hk_type type,
 static int __init housekeeping_setup(char *str, unsigned long flags)
 {
 	cpumask_var_t non_housekeeping_mask, housekeeping_staging;
+	unsigned int first_cpu;
 	int err = 0;
 
 	if ((flags & HK_FLAG_TICK) && !(housekeeping.flags & HK_FLAG_TICK)) {
@@ -129,7 +130,8 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
 	cpumask_andnot(housekeeping_staging,
 		       cpu_possible_mask, non_housekeeping_mask);
 
-	if (!cpumask_intersects(cpu_present_mask, housekeeping_staging)) {
+	first_cpu = cpumask_first_and(cpu_present_mask, housekeeping_staging);
+	if (first_cpu >= nr_cpu_ids || first_cpu >= setup_max_cpus) {
 		__cpumask_set_cpu(smp_processor_id(), housekeeping_staging);
 		__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
 		if (!housekeeping.flags) {
@@ -138,6 +140,9 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
 		}
 	}
 
+	if (cpumask_empty(non_housekeeping_mask))
+		goto free_housekeeping_staging;
+
 	if (!housekeeping.flags) {
 		/* First setup call ("nohz_full=" or "isolcpus=") */
 		enum hk_type type;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux