aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_sched_switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_sched_switch.c')
-rw-r--r--kernel/trace/trace_sched_switch.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index df175cb4564f..9117cea6f1ae 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -18,6 +18,7 @@ static struct trace_array *ctx_trace;
18static int __read_mostly tracer_enabled; 18static int __read_mostly tracer_enabled;
19static int sched_ref; 19static int sched_ref;
20static DEFINE_MUTEX(sched_register_mutex); 20static DEFINE_MUTEX(sched_register_mutex);
21static int sched_stopped;
21 22
22static void 23static void
23probe_sched_switch(struct rq *__rq, struct task_struct *prev, 24probe_sched_switch(struct rq *__rq, struct task_struct *prev,
@@ -28,7 +29,7 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,
28 int cpu; 29 int cpu;
29 int pc; 30 int pc;
30 31
31 if (!sched_ref) 32 if (!sched_ref || sched_stopped)
32 return; 33 return;
33 34
34 tracing_record_cmdline(prev); 35 tracing_record_cmdline(prev);
@@ -43,7 +44,7 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,
43 data = ctx_trace->data[cpu]; 44 data = ctx_trace->data[cpu];
44 45
45 if (likely(!atomic_read(&data->disabled))) 46 if (likely(!atomic_read(&data->disabled)))
46 tracing_sched_switch_trace(ctx_trace, data, prev, next, flags, pc); 47 tracing_sched_switch_trace(ctx_trace, prev, next, flags, pc);
47 48
48 local_irq_restore(flags); 49 local_irq_restore(flags);
49} 50}
@@ -61,12 +62,15 @@ probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success)
61 pc = preempt_count(); 62 pc = preempt_count();
62 tracing_record_cmdline(current); 63 tracing_record_cmdline(current);
63 64
65 if (sched_stopped)
66 return;
67
64 local_irq_save(flags); 68 local_irq_save(flags);
65 cpu = raw_smp_processor_id(); 69 cpu = raw_smp_processor_id();
66 data = ctx_trace->data[cpu]; 70 data = ctx_trace->data[cpu];
67 71
68 if (likely(!atomic_read(&data->disabled))) 72 if (likely(!atomic_read(&data->disabled)))
69 tracing_sched_wakeup_trace(ctx_trace, data, wakee, current, 73 tracing_sched_wakeup_trace(ctx_trace, wakee, current,
70 flags, pc); 74 flags, pc);
71 75
72 local_irq_restore(flags); 76 local_irq_restore(flags);
@@ -93,7 +97,7 @@ static int tracing_sched_register(void)
93 ret = register_trace_sched_switch(probe_sched_switch); 97 ret = register_trace_sched_switch(probe_sched_switch);
94 if (ret) { 98 if (ret) {
95 pr_info("sched trace: Couldn't activate tracepoint" 99 pr_info("sched trace: Couldn't activate tracepoint"
96 " probe to kernel_sched_schedule\n"); 100 " probe to kernel_sched_switch\n");
97 goto fail_deprobe_wake_new; 101 goto fail_deprobe_wake_new;
98 } 102 }
99 103
@@ -185,12 +189,6 @@ void tracing_sched_switch_assign_trace(struct trace_array *tr)
185 ctx_trace = tr; 189 ctx_trace = tr;
186} 190}
187 191
188static void start_sched_trace(struct trace_array *tr)
189{
190 tracing_reset_online_cpus(tr);
191 tracing_start_sched_switch_record();
192}
193
194static void stop_sched_trace(struct trace_array *tr) 192static void stop_sched_trace(struct trace_array *tr)
195{ 193{
196 tracing_stop_sched_switch_record(); 194 tracing_stop_sched_switch_record();
@@ -199,7 +197,8 @@ static void stop_sched_trace(struct trace_array *tr)
199static int sched_switch_trace_init(struct trace_array *tr) 197static int sched_switch_trace_init(struct trace_array *tr)
200{ 198{
201 ctx_trace = tr; 199 ctx_trace = tr;
202 start_sched_trace(tr); 200 tracing_reset_online_cpus(tr);
201 tracing_start_sched_switch_record();
203 return 0; 202 return 0;
204} 203}
205 204
@@ -211,13 +210,12 @@ static void sched_switch_trace_reset(struct trace_array *tr)
211 210
212static void sched_switch_trace_start(struct trace_array *tr) 211static void sched_switch_trace_start(struct trace_array *tr)
213{ 212{
214 tracing_reset_online_cpus(tr); 213 sched_stopped = 0;
215 tracing_start_sched_switch();
216} 214}
217 215
218static void sched_switch_trace_stop(struct trace_array *tr) 216static void sched_switch_trace_stop(struct trace_array *tr)
219{ 217{
220 tracing_stop_sched_switch(); 218 sched_stopped = 1;
221} 219}
222 220
223static struct tracer sched_switch_trace __read_mostly = 221static struct tracer sched_switch_trace __read_mostly =
@@ -227,6 +225,7 @@ static struct tracer sched_switch_trace __read_mostly =
227 .reset = sched_switch_trace_reset, 225 .reset = sched_switch_trace_reset,
228 .start = sched_switch_trace_start, 226 .start = sched_switch_trace_start,
229 .stop = sched_switch_trace_stop, 227 .stop = sched_switch_trace_stop,
228 .wait_pipe = poll_wait_pipe,
230#ifdef CONFIG_FTRACE_SELFTEST 229#ifdef CONFIG_FTRACE_SELFTEST
231 .selftest = trace_selftest_startup_sched_switch, 230 .selftest = trace_selftest_startup_sched_switch,
232#endif 231#endif