Re: [PATCH V4 05/12] trace/hwlat: Support hotplug operations

From
Steven Rostedt <rostedt@goodmis.org>
Date
2021-06-18 19:00:27
Also in
lkml
Reply to
Steven Rostedt, 2021-06-18
On Fri, 18 Jun 2021 12:45:03 -0400
Steven Rostedt [off-list ref] wrote:
quoted
+/*
+ * hwlat_cpu_init - CPU hotplug online callback function
+ */
+static int hwlat_cpu_init(unsigned int cpu)
+{
+	struct trace_array *tr = hwlat_trace;
+  
You need to take the trace_types_lock here, between testing the
hwlat_busy and starting the threads. Otherwise, between the two, the
hwlat tracer could be turned off while a CPU is coming on line, and
then you just started a per cpu thread, while the hwlat tracer is not
enabled.
And of course, because get_online_cpus() is called within
trace_types_lock, doing this check is going to cause a lock inversion.

The only thing I could think of is to wake up a worker thread to do the
work. That is, this just wakes the worker thread, then the worker grabs
the trace_types_lock, iterates through the cpu mask of expect running
threads, and then starts or kills them depending on the hwlat_busy
value.

-- Steve
quoted
+	if (!hwlat_busy)
+		return 0;
+
+	if (!cpumask_test_cpu(cpu, tr->tracing_cpumask))
+		return 0;
+
+	return start_cpu_kthread(cpu);
+}
Thread (28 messages) 28 messages, 2 authors, last reply 2021-06-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help