lkml.org 
[lkml]   [2017]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC][PATCH 4/5] tracepoints: Grab get_online_cpus() before taking tracepoints_mutex
    From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

    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@goodmis.org>
    ---
    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

    \
     
     \ /
      Last update: 2017-05-12 19:27    [W:3.289 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site