[RFC][PATCH 4/5] tracepoints: Grab get_online_cpus() before taking tracepoints_mutex

From: Steven Rostedt
Date: Fri May 12 2017 - 13:27:20 EST


From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

There's places that take tracepoints_mutex while holding get_online_cpus(),
and since tracepoints call jump_label code, which also takes
get_online_cpus(), make sure that the tracepoints_mutex is always taken
under get_online_cpus().

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
kernel/tracepoint.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 685c50ae6300..e41eab51b435 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -23,6 +23,7 @@
#include <linux/rcupdate.h>
#include <linux/tracepoint.h>
#include <linux/err.h>
+#include <linux/cpu.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>
#include <linux/sched/task.h>
@@ -276,12 +277,14 @@ int tracepoint_probe_register_prio(struct tracepoint *tp, void *probe,
struct tracepoint_func tp_func;
int ret;

+ get_online_cpus();
mutex_lock(&tracepoints_mutex);
tp_func.func = probe;
tp_func.data = data;
tp_func.prio = prio;
ret = tracepoint_add_func(tp, &tp_func, prio);
mutex_unlock(&tracepoints_mutex);
+ put_online_cpus();
return ret;
}
EXPORT_SYMBOL_GPL(tracepoint_probe_register_prio);
@@ -318,11 +321,13 @@ int tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data)
struct tracepoint_func tp_func;
int ret;

+ get_online_cpus();
mutex_lock(&tracepoints_mutex);
tp_func.func = probe;
tp_func.data = data;
ret = tracepoint_remove_func(tp, &tp_func);
mutex_unlock(&tracepoints_mutex);
+ put_online_cpus();
return ret;
}
EXPORT_SYMBOL_GPL(tracepoint_probe_unregister);
--
2.10.2