Two fixes for the SMP core:

 - Make the warning condition in flush_smp_call_function_queue() correct,
   which checks a just emptied list head for being empty instead of
   validating that there was no pending entry on the offlined CPU at all.

 - The @cpu member of struct cpuhp_cpu_state is initialized when the CPU
   hotplug thread for the upcoming CPU is created. That's too late because
   the creation of the thread can fail and then the following rollback
   operates on CPU0. Get rid of the CPU member and hand the CPU number to
   the involved functions directly.
cpu/hotplug: Remove the 'cpu' member of cpuhp_cpu_state

Currently the setting of the 'cpu' member of struct cpuhp_cpu_state in
cpuhp_create() is too late as it is used earlier in _cpu_up().

If kzalloc_node() in __smpboot_create_thread() fails then the rollback will
be done with st->cpu==0 causing CPU0 to be erroneously set to be dying,
causing the scheduler to get mightily confused and throw its toys out of
the pram.

However the cpu number is actually available directly, so simply remove
the 'cpu' member and avoid the problem in the first place.

Fixes: 2ea46c6fc945 ("cpumask/hotplug: Fix cpu_dying() state tracking")
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20220411152233.474129-2-steven.price@arm.com

1 file changed