Commit efade6e7821c4219818e9da08f9315dfa617048b

Authored by Frederic Weisbecker
Committed by Ingo Molnar
1 parent d7ad44b697

tracing/ftrace: types and naming corrections for sched tracer

Impact: cleanup

This patch applies some corrections suggested by Steven Rostedt.

Change the type of shed_ref into int since it is used
into a Mutex, we don't need it anymore as an atomic
variable in the sched_switch tracer.
Also change the name of the register mutex.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 13 additions and 17 deletions Side-by-side Diff

kernel/trace/trace_sched_switch.c
... ... @@ -16,8 +16,8 @@
16 16  
17 17 static struct trace_array *ctx_trace;
18 18 static int __read_mostly tracer_enabled;
19   -static atomic_t sched_ref;
20   -static DEFINE_MUTEX(tracepoint_mutex);
  19 +static int sched_ref;
  20 +static DEFINE_MUTEX(sched_register_mutex);
21 21  
22 22 static void
23 23 probe_sched_switch(struct rq *__rq, struct task_struct *prev,
... ... @@ -28,7 +28,7 @@
28 28 int cpu;
29 29 int pc;
30 30  
31   - if (!atomic_read(&sched_ref))
  31 + if (!sched_ref)
32 32 return;
33 33  
34 34 tracing_record_cmdline(prev);
35 35  
36 36  
37 37  
... ... @@ -124,26 +124,22 @@
124 124  
125 125 static void tracing_start_sched_switch(void)
126 126 {
127   - long ref;
128   -
129   - mutex_lock(&tracepoint_mutex);
130   - tracer_enabled = 1;
131   - ref = atomic_inc_return(&sched_ref);
132   - if (ref == 1)
  127 + mutex_lock(&sched_register_mutex);
  128 + if (!(sched_ref++)) {
  129 + tracer_enabled = 1;
133 130 tracing_sched_register();
134   - mutex_unlock(&tracepoint_mutex);
  131 + }
  132 + mutex_unlock(&sched_register_mutex);
135 133 }
136 134  
137 135 static void tracing_stop_sched_switch(void)
138 136 {
139   - long ref;
140   -
141   - mutex_lock(&tracepoint_mutex);
142   - tracer_enabled = 0;
143   - ref = atomic_dec_and_test(&sched_ref);
144   - if (ref)
  137 + mutex_lock(&sched_register_mutex);
  138 + if (!(--sched_ref)) {
145 139 tracing_sched_unregister();
146   - mutex_unlock(&tracepoint_mutex);
  140 + tracer_enabled = 0;
  141 + }
  142 + mutex_unlock(&sched_register_mutex);
147 143 }
148 144  
149 145 void tracing_start_cmdline_record(void)