diff options
-rw-r--r-- | kernel/trace/trace.c | 7 | ||||
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_functions.c | 2 | ||||
-rw-r--r-- | kernel/trace/trace_sched_switch.c | 7 |
4 files changed, 15 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a102b11eacf2..1281969103b8 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -620,7 +620,12 @@ static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; | |||
620 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; | 620 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; |
621 | static int cmdline_idx; | 621 | static int cmdline_idx; |
622 | static DEFINE_SPINLOCK(trace_cmdline_lock); | 622 | static DEFINE_SPINLOCK(trace_cmdline_lock); |
623 | atomic_t trace_record_cmdline_disabled; | 623 | |
624 | /* trace in all context switches */ | ||
625 | atomic_t trace_record_cmdline_enabled __read_mostly; | ||
626 | |||
627 | /* temporary disable recording */ | ||
628 | atomic_t trace_record_cmdline_disabled __read_mostly; | ||
624 | 629 | ||
625 | static void trace_init_cmdlines(void) | 630 | static void trace_init_cmdlines(void) |
626 | { | 631 | { |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 21c29ee13e53..8991c5efcc74 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -216,6 +216,8 @@ extern unsigned long nsecs_to_usecs(unsigned long nsecs); | |||
216 | extern unsigned long tracing_max_latency; | 216 | extern unsigned long tracing_max_latency; |
217 | extern unsigned long tracing_thresh; | 217 | extern unsigned long tracing_thresh; |
218 | 218 | ||
219 | extern atomic_t trace_record_cmdline_enabled; | ||
220 | |||
219 | void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); | 221 | void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); |
220 | void update_max_tr_single(struct trace_array *tr, | 222 | void update_max_tr_single(struct trace_array *tr, |
221 | struct task_struct *tsk, int cpu); | 223 | struct task_struct *tsk, int cpu); |
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 4165d34bd28a..0a084656d7cf 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c | |||
@@ -29,12 +29,14 @@ static void function_reset(struct trace_array *tr) | |||
29 | static void start_function_trace(struct trace_array *tr) | 29 | static void start_function_trace(struct trace_array *tr) |
30 | { | 30 | { |
31 | function_reset(tr); | 31 | function_reset(tr); |
32 | atomic_inc(&trace_record_cmdline_enabled); | ||
32 | tracing_start_function_trace(); | 33 | tracing_start_function_trace(); |
33 | } | 34 | } |
34 | 35 | ||
35 | static void stop_function_trace(struct trace_array *tr) | 36 | static void stop_function_trace(struct trace_array *tr) |
36 | { | 37 | { |
37 | tracing_stop_function_trace(); | 38 | tracing_stop_function_trace(); |
39 | atomic_dec(&trace_record_cmdline_enabled); | ||
38 | } | 40 | } |
39 | 41 | ||
40 | static void function_trace_init(struct trace_array *tr) | 42 | static void function_trace_init(struct trace_array *tr) |
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c index 5671db0e1827..a3376478fc2c 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c | |||
@@ -29,8 +29,6 @@ ctx_switch_func(void *__rq, struct task_struct *prev, struct task_struct *next) | |||
29 | if (!tracer_enabled) | 29 | if (!tracer_enabled) |
30 | return; | 30 | return; |
31 | 31 | ||
32 | tracing_record_cmdline(prev); | ||
33 | |||
34 | local_irq_save(flags); | 32 | local_irq_save(flags); |
35 | cpu = raw_smp_processor_id(); | 33 | cpu = raw_smp_processor_id(); |
36 | data = tr->data[cpu]; | 34 | data = tr->data[cpu]; |
@@ -73,6 +71,9 @@ void | |||
73 | ftrace_ctx_switch(void *__rq, struct task_struct *prev, | 71 | ftrace_ctx_switch(void *__rq, struct task_struct *prev, |
74 | struct task_struct *next) | 72 | struct task_struct *next) |
75 | { | 73 | { |
74 | if (unlikely(atomic_read(&trace_record_cmdline_enabled))) | ||
75 | tracing_record_cmdline(prev); | ||
76 | |||
76 | /* | 77 | /* |
77 | * If tracer_switch_func only points to the local | 78 | * If tracer_switch_func only points to the local |
78 | * switch func, it still needs the ptr passed to it. | 79 | * switch func, it still needs the ptr passed to it. |
@@ -134,11 +135,13 @@ static void sched_switch_reset(struct trace_array *tr) | |||
134 | static void start_sched_trace(struct trace_array *tr) | 135 | static void start_sched_trace(struct trace_array *tr) |
135 | { | 136 | { |
136 | sched_switch_reset(tr); | 137 | sched_switch_reset(tr); |
138 | atomic_inc(&trace_record_cmdline_enabled); | ||
137 | tracer_enabled = 1; | 139 | tracer_enabled = 1; |
138 | } | 140 | } |
139 | 141 | ||
140 | static void stop_sched_trace(struct trace_array *tr) | 142 | static void stop_sched_trace(struct trace_array *tr) |
141 | { | 143 | { |
144 | atomic_dec(&trace_record_cmdline_enabled); | ||
142 | tracer_enabled = 0; | 145 | tracer_enabled = 0; |
143 | } | 146 | } |
144 | 147 | ||