aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c64
1 files changed, 28 insertions, 36 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 113aea9447ec..ff1e9ed9b587 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -150,6 +150,19 @@ static DEFINE_PER_CPU(struct trace_array_cpu, max_data);
150/* tracer_enabled is used to toggle activation of a tracer */ 150/* tracer_enabled is used to toggle activation of a tracer */
151static int tracer_enabled = 1; 151static int tracer_enabled = 1;
152 152
153/**
154 * tracing_is_enabled - return tracer_enabled status
155 *
156 * This function is used by other tracers to know the status
157 * of the tracer_enabled flag. Tracers may use this function
158 * to know if it should enable their features when starting
159 * up. See irqsoff tracer for an example (start_irqsoff_tracer).
160 */
161int tracing_is_enabled(void)
162{
163 return tracer_enabled;
164}
165
153/* function tracing enabled */ 166/* function tracing enabled */
154int ftrace_function_enabled; 167int ftrace_function_enabled;
155 168
@@ -1041,8 +1054,7 @@ void tracing_start_function_trace(void)
1041 trace_ops.func = function_trace_call; 1054 trace_ops.func = function_trace_call;
1042 1055
1043 register_ftrace_function(&trace_ops); 1056 register_ftrace_function(&trace_ops);
1044 if (tracer_enabled) 1057 ftrace_function_enabled = 1;
1045 ftrace_function_enabled = 1;
1046} 1058}
1047 1059
1048void tracing_stop_function_trace(void) 1060void tracing_stop_function_trace(void)
@@ -1189,10 +1201,6 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1189 1201
1190 atomic_inc(&trace_record_cmdline_disabled); 1202 atomic_inc(&trace_record_cmdline_disabled);
1191 1203
1192 /* let the tracer grab locks here if needed */
1193 if (current_trace->start)
1194 current_trace->start(iter);
1195
1196 if (*pos != iter->pos) { 1204 if (*pos != iter->pos) {
1197 iter->ent = NULL; 1205 iter->ent = NULL;
1198 iter->cpu = 0; 1206 iter->cpu = 0;
@@ -1219,14 +1227,7 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1219 1227
1220static void s_stop(struct seq_file *m, void *p) 1228static void s_stop(struct seq_file *m, void *p)
1221{ 1229{
1222 struct trace_iterator *iter = m->private;
1223
1224 atomic_dec(&trace_record_cmdline_disabled); 1230 atomic_dec(&trace_record_cmdline_disabled);
1225
1226 /* let the tracer release locks here if needed */
1227 if (current_trace && current_trace == iter->trace && iter->trace->stop)
1228 iter->trace->stop(iter);
1229
1230 mutex_unlock(&trace_types_lock); 1231 mutex_unlock(&trace_types_lock);
1231} 1232}
1232 1233
@@ -2056,10 +2057,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
2056 m->private = iter; 2057 m->private = iter;
2057 2058
2058 /* stop the trace while dumping */ 2059 /* stop the trace while dumping */
2059 if (iter->tr->ctrl) { 2060 tracing_stop();
2060 tracer_enabled = 0;
2061 ftrace_function_enabled = 0;
2062 }
2063 2061
2064 if (iter->trace && iter->trace->open) 2062 if (iter->trace && iter->trace->open)
2065 iter->trace->open(iter); 2063 iter->trace->open(iter);
@@ -2104,14 +2102,7 @@ int tracing_release(struct inode *inode, struct file *file)
2104 iter->trace->close(iter); 2102 iter->trace->close(iter);
2105 2103
2106 /* reenable tracing if it was previously enabled */ 2104 /* reenable tracing if it was previously enabled */
2107 if (iter->tr->ctrl) { 2105 tracing_start();
2108 tracer_enabled = 1;
2109 /*
2110 * It is safe to enable function tracing even if it
2111 * isn't used
2112 */
2113 ftrace_function_enabled = 1;
2114 }
2115 mutex_unlock(&trace_types_lock); 2106 mutex_unlock(&trace_types_lock);
2116 2107
2117 seq_release(inode, file); 2108 seq_release(inode, file);
@@ -2449,11 +2440,10 @@ static ssize_t
2449tracing_ctrl_read(struct file *filp, char __user *ubuf, 2440tracing_ctrl_read(struct file *filp, char __user *ubuf,
2450 size_t cnt, loff_t *ppos) 2441 size_t cnt, loff_t *ppos)
2451{ 2442{
2452 struct trace_array *tr = filp->private_data;
2453 char buf[64]; 2443 char buf[64];
2454 int r; 2444 int r;
2455 2445
2456 r = sprintf(buf, "%ld\n", tr->ctrl); 2446 r = sprintf(buf, "%u\n", tracer_enabled);
2457 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 2447 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2458} 2448}
2459 2449
@@ -2481,16 +2471,18 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
2481 val = !!val; 2471 val = !!val;
2482 2472
2483 mutex_lock(&trace_types_lock); 2473 mutex_lock(&trace_types_lock);
2484 if (tr->ctrl ^ val) { 2474 if (tracer_enabled ^ val) {
2485 if (val) 2475 if (val) {
2486 tracer_enabled = 1; 2476 tracer_enabled = 1;
2487 else 2477 if (current_trace->start)
2478 current_trace->start(tr);
2479 tracing_start();
2480 } else {
2488 tracer_enabled = 0; 2481 tracer_enabled = 0;
2489 2482 tracing_stop();
2490 tr->ctrl = val; 2483 if (current_trace->stop)
2491 2484 current_trace->stop(tr);
2492 if (current_trace && current_trace->ctrl_update) 2485 }
2493 current_trace->ctrl_update(tr);
2494 } 2486 }
2495 mutex_unlock(&trace_types_lock); 2487 mutex_unlock(&trace_types_lock);
2496 2488
@@ -3372,7 +3364,7 @@ __init static int tracer_alloc_buffers(void)
3372#endif 3364#endif
3373 3365
3374 /* All seems OK, enable tracing */ 3366 /* All seems OK, enable tracing */
3375 global_trace.ctrl = tracer_enabled; 3367 global_trace.ctrl = 1;
3376 tracing_disabled = 0; 3368 tracing_disabled = 0;
3377 3369
3378 atomic_notifier_chain_register(&panic_notifier_list, 3370 atomic_notifier_chain_register(&panic_notifier_list,