smp_processor_id() should be called with migration disabled. This mean we may safely call smp_processor_id() in percpu thread. However, this is not the case if the work is (re-)queued into unbound workqueue, during cpu-hotplog. So, detect and return early if this work happens to run on an unbound wq.
Signed-off-by: Andy Chiu <[email protected]> --- kernel/trace/trace_osnoise.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index bd0d01d00fb9..cf7f716d3f35 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -2068,7 +2068,12 @@ static int start_per_cpu_kthreads(void) #ifdef CONFIG_HOTPLUG_CPU static void osnoise_hotplug_workfn(struct work_struct *dummy) { - unsigned int cpu = smp_processor_id(); + unsigned int cpu; + + if (!is_percpu_thread()) + return; + + cpu = smp_processor_id(); mutex_lock(&trace_types_lock); -- 2.43.0
