diff options
-rw-r--r-- | kernel/trace/trace_sched_switch.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c index b8f56beb1a62..59de5141207c 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c | |||
@@ -17,6 +17,7 @@ | |||
17 | static struct trace_array *ctx_trace; | 17 | static struct trace_array *ctx_trace; |
18 | static int __read_mostly tracer_enabled; | 18 | static int __read_mostly tracer_enabled; |
19 | static atomic_t sched_ref; | 19 | static atomic_t sched_ref; |
20 | static DEFINE_MUTEX(tracepoint_mutex); | ||
20 | 21 | ||
21 | static void | 22 | static void |
22 | probe_sched_switch(struct rq *__rq, struct task_struct *prev, | 23 | probe_sched_switch(struct rq *__rq, struct task_struct *prev, |
@@ -125,18 +126,22 @@ static void tracing_start_sched_switch(void) | |||
125 | { | 126 | { |
126 | long ref; | 127 | long ref; |
127 | 128 | ||
129 | mutex_lock(&tracepoint_mutex); | ||
128 | ref = atomic_inc_return(&sched_ref); | 130 | ref = atomic_inc_return(&sched_ref); |
129 | if (ref == 1) | 131 | if (ref == 1) |
130 | tracing_sched_register(); | 132 | tracing_sched_register(); |
133 | mutex_unlock(&tracepoint_mutex); | ||
131 | } | 134 | } |
132 | 135 | ||
133 | static void tracing_stop_sched_switch(void) | 136 | static void tracing_stop_sched_switch(void) |
134 | { | 137 | { |
135 | long ref; | 138 | long ref; |
136 | 139 | ||
140 | mutex_lock(&tracepoint_mutex); | ||
137 | ref = atomic_dec_and_test(&sched_ref); | 141 | ref = atomic_dec_and_test(&sched_ref); |
138 | if (ref) | 142 | if (ref) |
139 | tracing_sched_unregister(); | 143 | tracing_sched_unregister(); |
144 | mutex_unlock(&tracepoint_mutex); | ||
140 | } | 145 | } |
141 | 146 | ||
142 | void tracing_start_cmdline_record(void) | 147 | void tracing_start_cmdline_record(void) |