If the task happens to run after cpu hot-plug offline, then it would not
be running in a percpu_thread. Instead, it would be re-queued into a
UNBOUND workqueue. This would trigger a warning if we enable kernel
preemption.

Signed-off-by: Andy Chiu <andy.c...@sifive.com>
---
 kernel/trace/trace_hwlat.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index b791524a6536..87258ddc2141 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -511,7 +511,16 @@ static int start_cpu_kthread(unsigned int cpu)
 static void hwlat_hotplug_workfn(struct work_struct *dummy)
 {
        struct trace_array *tr = hwlat_trace;
-       unsigned int cpu = smp_processor_id();
+       unsigned int cpu;
+
+       /*
+        * If the work is scheduled after CPU hotplug offline being invoked,
+        * then it would be queued into UNBOUNDED workqueue
+        */
+       if (!is_percpu_thread())
+               return;
+
+       cpu = smp_processor_id();
 
        mutex_lock(&trace_types_lock);
        mutex_lock(&hwlat_data.lock);
-- 
2.43.0


Reply via email to