aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-11-07 22:36:02 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-08 03:51:18 -0500
commite168e0516e476070faa9e8e7b23dfcba79b76d82 (patch)
tree21b1bad3def7f6cd88d9adfe1b09973fc70f864a /kernel
parent75f5c47da386445ba0c5a8b7e3ca0c906e763369 (diff)
ftrace: fix sched_switch API
Impact: fix for sched_switch that broke dynamic ftrace startup The commit: tracing/fastboot: use sched switch tracer from boot tracer broke the API of the sched_switch trace. The use of the tracing_start/stop_cmdline record is for only recording the cmdline, NOT recording the schedule switches themselves. Seeing that the boot tracer broke the API to do something that it wanted, this patch adds a new interface for the API while puting back the original interface of the old API. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.h4
-rw-r--r--kernel/trace/trace_boot.c6
-rw-r--r--kernel/trace/trace_sched_switch.c50
3 files changed, 46 insertions, 14 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index db12e16137e1..25abfc45f081 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -324,7 +324,9 @@ void trace_function(struct trace_array *tr,
324 324
325void tracing_start_cmdline_record(void); 325void tracing_start_cmdline_record(void);
326void tracing_stop_cmdline_record(void); 326void tracing_stop_cmdline_record(void);
327void tracing_cmdline_assign_trace(struct trace_array *tr); 327void tracing_sched_switch_assign_trace(struct trace_array *tr);
328void tracing_stop_sched_switch_record(void);
329void tracing_start_sched_switch_record(void);
328int register_tracer(struct tracer *type); 330int register_tracer(struct tracer *type);
329void unregister_tracer(struct tracer *type); 331void unregister_tracer(struct tracer *type);
330 332
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index 662cb9198906..0203c1054012 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -28,13 +28,13 @@ void start_boot_trace(void)
28void enable_boot_trace(void) 28void enable_boot_trace(void)
29{ 29{
30 if (pre_initcalls_finished) 30 if (pre_initcalls_finished)
31 tracing_start_cmdline_record(); 31 tracing_start_sched_switch_record();
32} 32}
33 33
34void disable_boot_trace(void) 34void disable_boot_trace(void)
35{ 35{
36 if (pre_initcalls_finished) 36 if (pre_initcalls_finished)
37 tracing_stop_cmdline_record(); 37 tracing_stop_sched_switch_record();
38} 38}
39 39
40static void reset_boot_trace(struct trace_array *tr) 40static void reset_boot_trace(struct trace_array *tr)
@@ -55,7 +55,7 @@ static void boot_trace_init(struct trace_array *tr)
55 for_each_cpu_mask(cpu, cpu_possible_map) 55 for_each_cpu_mask(cpu, cpu_possible_map)
56 tracing_reset(tr, cpu); 56 tracing_reset(tr, cpu);
57 57
58 tracing_cmdline_assign_trace(tr); 58 tracing_sched_switch_assign_trace(tr);
59} 59}
60 60
61static void boot_trace_ctrl_update(struct trace_array *tr) 61static void boot_trace_ctrl_update(struct trace_array *tr)
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index fbf05df7134d..79410db64d6f 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -125,20 +125,16 @@ static void tracing_sched_unregister(void)
125static void tracing_start_sched_switch(void) 125static void tracing_start_sched_switch(void)
126{ 126{
127 mutex_lock(&sched_register_mutex); 127 mutex_lock(&sched_register_mutex);
128 if (!(sched_ref++)) { 128 if (!(sched_ref++))
129 tracer_enabled = 1;
130 tracing_sched_register(); 129 tracing_sched_register();
131 }
132 mutex_unlock(&sched_register_mutex); 130 mutex_unlock(&sched_register_mutex);
133} 131}
134 132
135static void tracing_stop_sched_switch(void) 133static void tracing_stop_sched_switch(void)
136{ 134{
137 mutex_lock(&sched_register_mutex); 135 mutex_lock(&sched_register_mutex);
138 if (!(--sched_ref)) { 136 if (!(--sched_ref))
139 tracing_sched_unregister(); 137 tracing_sched_unregister();
140 tracer_enabled = 0;
141 }
142 mutex_unlock(&sched_register_mutex); 138 mutex_unlock(&sched_register_mutex);
143} 139}
144 140
@@ -153,14 +149,48 @@ void tracing_stop_cmdline_record(void)
153} 149}
154 150
155/** 151/**
156 * tracing_cmdline_assign_trace - assign a trace array for ctx switch 152 * tracing_start_sched_switch_record - start tracing context switches
153 *
154 * Turns on context switch tracing for a tracer.
155 */
156void tracing_start_sched_switch_record(void)
157{
158 if (unlikely(!ctx_trace)) {
159 WARN_ON(1);
160 return;
161 }
162
163 tracing_start_sched_switch();
164
165 mutex_lock(&sched_register_mutex);
166 tracer_enabled++;
167 mutex_unlock(&sched_register_mutex);
168}
169
170/**
171 * tracing_stop_sched_switch_record - start tracing context switches
172 *
173 * Turns off context switch tracing for a tracer.
174 */
175void tracing_stop_sched_switch_record(void)
176{
177 mutex_lock(&sched_register_mutex);
178 tracer_enabled--;
179 WARN_ON(tracer_enabled < 0);
180 mutex_unlock(&sched_register_mutex);
181
182 tracing_stop_sched_switch();
183}
184
185/**
186 * tracing_sched_switch_assign_trace - assign a trace array for ctx switch
157 * @tr: trace array pointer to assign 187 * @tr: trace array pointer to assign
158 * 188 *
159 * Some tracers might want to record the context switches in their 189 * Some tracers might want to record the context switches in their
160 * trace. This function lets those tracers assign the trace array 190 * trace. This function lets those tracers assign the trace array
161 * to use. 191 * to use.
162 */ 192 */
163void tracing_cmdline_assign_trace(struct trace_array *tr) 193void tracing_sched_switch_assign_trace(struct trace_array *tr)
164{ 194{
165 ctx_trace = tr; 195 ctx_trace = tr;
166} 196}
@@ -168,12 +198,12 @@ void tracing_cmdline_assign_trace(struct trace_array *tr)
168static void start_sched_trace(struct trace_array *tr) 198static void start_sched_trace(struct trace_array *tr)
169{ 199{
170 sched_switch_reset(tr); 200 sched_switch_reset(tr);
171 tracing_start_cmdline_record(); 201 tracing_start_sched_switch_record();
172} 202}
173 203
174static void stop_sched_trace(struct trace_array *tr) 204static void stop_sched_trace(struct trace_array *tr)
175{ 205{
176 tracing_stop_cmdline_record(); 206 tracing_stop_sched_switch_record();
177} 207}
178 208
179static void sched_switch_trace_init(struct trace_array *tr) 209static void sched_switch_trace_init(struct trace_array *tr)