diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.h | 4 | ||||
-rw-r--r-- | kernel/trace/trace_boot.c | 6 | ||||
-rw-r--r-- | kernel/trace/trace_sched_switch.c | 50 |
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 | ||
325 | void tracing_start_cmdline_record(void); | 325 | void tracing_start_cmdline_record(void); |
326 | void tracing_stop_cmdline_record(void); | 326 | void tracing_stop_cmdline_record(void); |
327 | void tracing_cmdline_assign_trace(struct trace_array *tr); | 327 | void tracing_sched_switch_assign_trace(struct trace_array *tr); |
328 | void tracing_stop_sched_switch_record(void); | ||
329 | void tracing_start_sched_switch_record(void); | ||
328 | int register_tracer(struct tracer *type); | 330 | int register_tracer(struct tracer *type); |
329 | void unregister_tracer(struct tracer *type); | 331 | void 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) | |||
28 | void enable_boot_trace(void) | 28 | void 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 | ||
34 | void disable_boot_trace(void) | 34 | void 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 | ||
40 | static void reset_boot_trace(struct trace_array *tr) | 40 | static 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 | ||
61 | static void boot_trace_ctrl_update(struct trace_array *tr) | 61 | static 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) | |||
125 | static void tracing_start_sched_switch(void) | 125 | static 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 | ||
135 | static void tracing_stop_sched_switch(void) | 133 | static 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 | */ | ||
156 | void 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 | */ | ||
175 | void 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 | */ |
163 | void tracing_cmdline_assign_trace(struct trace_array *tr) | 193 | void 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) | |||
168 | static void start_sched_trace(struct trace_array *tr) | 198 | static 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 | ||
174 | static void stop_sched_trace(struct trace_array *tr) | 204 | static 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 | ||
179 | static void sched_switch_trace_init(struct trace_array *tr) | 209 | static void sched_switch_trace_init(struct trace_array *tr) |