On Mon, Oct 16, 2023 at 11:50:34AM -0700, srinivas pandruvada wrote:
I'll respond to the rest tomorrow, it's far too late.
Also, same question as to the amd folks; what serializes those static variables?
That's a good one.
This function which is checking static variables is called from cpufreq ->init callback. Which in turn is called from a function which is passed as startup() function pointer to cpuhp_setup_state_nocalls_cpuslocked().
I see that startup() callbacks are called under a mutex cpuhp_state_mutex for each present CPUs. So if some tear down happen, that is also protected by the same mutex. The assumption is here is that cpuhp_invoke_callback() in hotplug state machine is not called in parallel on two CPUs by the hotplug state machine. But I see activity on parallel bringup, so this is questionable now.
Parallel bringup should still serialise this. It mostly only does the hardware bringup in parallel.
Having a pointer back to the cpu hotplug lock would make it easier to untangle this code though.