aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-05-11 14:25:30 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-11-02 10:21:50 -0400
commit0fb9656d957d79dbe7ae155bb6533b1d465e4a50 (patch)
treeb1c890432c60836b7c2d267249d85e91a17b58c5 /kernel/trace
parentc7b84ecada9a8b7fe3e6c081e70801703897ed5d (diff)
tracing: Make tracing_enabled be equal to tracing_on
The tracing_enabled file has been deprecated as it never was able to serve its purpose well. The tracing_on file has taken over. Instead of having code to keep tracing_enabled, have the tracing_enabled file just set tracing_on, and remove the tracing_enabled variable. This allows us to remove the tracing_enabled file. The reason that the remove is in a different change set and not removed here is in case we find some lonely userspace tool that requires the file to exist. Then the removal patch will get reverted, but this one will not. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace.c79
-rw-r--r--kernel/trace/trace_selftest.c12
2 files changed, 5 insertions, 86 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d1d8039578ab..3c9b96aee51a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -205,20 +205,9 @@ static struct trace_array max_tr;
205 205
206static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data); 206static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data);
207 207
208/* tracer_enabled is used to toggle activation of a tracer */
209static int tracer_enabled = 1;
210
211/**
212 * tracing_is_enabled - return tracer_enabled status
213 *
214 * This function is used by other tracers to know the status
215 * of the tracer_enabled flag. Tracers may use this function
216 * to know if it should enable their features when starting
217 * up. See irqsoff tracer for an example (start_irqsoff_tracer).
218 */
219int tracing_is_enabled(void) 208int tracing_is_enabled(void)
220{ 209{
221 return tracer_enabled; 210 return tracing_is_on();
222} 211}
223 212
224/* 213/*
@@ -1112,8 +1101,7 @@ void trace_find_cmdline(int pid, char comm[])
1112 1101
1113void tracing_record_cmdline(struct task_struct *tsk) 1102void tracing_record_cmdline(struct task_struct *tsk)
1114{ 1103{
1115 if (atomic_read(&trace_record_cmdline_disabled) || !tracer_enabled || 1104 if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())
1116 !tracing_is_on())
1117 return; 1105 return;
1118 1106
1119 if (!__this_cpu_read(trace_cmdline_save)) 1107 if (!__this_cpu_read(trace_cmdline_save))
@@ -2967,56 +2955,6 @@ static const struct file_operations tracing_saved_cmdlines_fops = {
2967}; 2955};
2968 2956
2969static ssize_t 2957static ssize_t
2970tracing_ctrl_read(struct file *filp, char __user *ubuf,
2971 size_t cnt, loff_t *ppos)
2972{
2973 char buf[64];
2974 int r;
2975
2976 r = sprintf(buf, "%u\n", tracer_enabled);
2977 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2978}
2979
2980static ssize_t
2981tracing_ctrl_write(struct file *filp, const char __user *ubuf,
2982 size_t cnt, loff_t *ppos)
2983{
2984 struct trace_array *tr = filp->private_data;
2985 unsigned long val;
2986 int ret;
2987
2988 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
2989 if (ret)
2990 return ret;
2991
2992 val = !!val;
2993
2994 mutex_lock(&trace_types_lock);
2995 if (tracer_enabled ^ val) {
2996
2997 /* Only need to warn if this is used to change the state */
2998 WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on");
2999
3000 if (val) {
3001 tracer_enabled = 1;
3002 if (current_trace->start)
3003 current_trace->start(tr);
3004 tracing_start();
3005 } else {
3006 tracer_enabled = 0;
3007 tracing_stop();
3008 if (current_trace->stop)
3009 current_trace->stop(tr);
3010 }
3011 }
3012 mutex_unlock(&trace_types_lock);
3013
3014 *ppos += cnt;
3015
3016 return cnt;
3017}
3018
3019static ssize_t
3020tracing_set_trace_read(struct file *filp, char __user *ubuf, 2958tracing_set_trace_read(struct file *filp, char __user *ubuf,
3021 size_t cnt, loff_t *ppos) 2959 size_t cnt, loff_t *ppos)
3022{ 2960{
@@ -3469,7 +3407,7 @@ static int tracing_wait_pipe(struct file *filp)
3469 return -EINTR; 3407 return -EINTR;
3470 3408
3471 /* 3409 /*
3472 * We block until we read something and tracing is disabled. 3410 * We block until we read something and tracing is enabled.
3473 * We still block if tracing is disabled, but we have never 3411 * We still block if tracing is disabled, but we have never
3474 * read anything. This allows a user to cat this file, and 3412 * read anything. This allows a user to cat this file, and
3475 * then enable tracing. But after we have read something, 3413 * then enable tracing. But after we have read something,
@@ -3477,7 +3415,7 @@ static int tracing_wait_pipe(struct file *filp)
3477 * 3415 *
3478 * iter->pos will be 0 if we haven't read anything. 3416 * iter->pos will be 0 if we haven't read anything.
3479 */ 3417 */
3480 if (!tracer_enabled && iter->pos) 3418 if (tracing_is_enabled() && iter->pos)
3481 break; 3419 break;
3482 } 3420 }
3483 3421
@@ -4076,13 +4014,6 @@ static const struct file_operations tracing_max_lat_fops = {
4076 .llseek = generic_file_llseek, 4014 .llseek = generic_file_llseek,
4077}; 4015};
4078 4016
4079static const struct file_operations tracing_ctrl_fops = {
4080 .open = tracing_open_generic,
4081 .read = tracing_ctrl_read,
4082 .write = tracing_ctrl_write,
4083 .llseek = generic_file_llseek,
4084};
4085
4086static const struct file_operations set_tracer_fops = { 4017static const struct file_operations set_tracer_fops = {
4087 .open = tracing_open_generic, 4018 .open = tracing_open_generic,
4088 .read = tracing_set_trace_read, 4019 .read = tracing_set_trace_read,
@@ -4858,7 +4789,7 @@ static __init int tracer_init_debugfs(void)
4858 d_tracer = tracing_init_dentry(); 4789 d_tracer = tracing_init_dentry();
4859 4790
4860 trace_create_file("tracing_enabled", 0644, d_tracer, 4791 trace_create_file("tracing_enabled", 0644, d_tracer,
4861 &global_trace, &tracing_ctrl_fops); 4792 &global_trace, &rb_simple_fops);
4862 4793
4863 trace_create_file("trace_options", 0644, d_tracer, 4794 trace_create_file("trace_options", 0644, d_tracer,
4864 NULL, &tracing_iter_fops); 4795 NULL, &tracing_iter_fops);
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 2c00a691a540..091b815f7b0a 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -320,7 +320,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
320 int (*func)(void)) 320 int (*func)(void))
321{ 321{
322 int save_ftrace_enabled = ftrace_enabled; 322 int save_ftrace_enabled = ftrace_enabled;
323 int save_tracer_enabled = tracer_enabled;
324 unsigned long count; 323 unsigned long count;
325 char *func_name; 324 char *func_name;
326 int ret; 325 int ret;
@@ -331,7 +330,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
331 330
332 /* enable tracing, and record the filter function */ 331 /* enable tracing, and record the filter function */
333 ftrace_enabled = 1; 332 ftrace_enabled = 1;
334 tracer_enabled = 1;
335 333
336 /* passed in by parameter to fool gcc from optimizing */ 334 /* passed in by parameter to fool gcc from optimizing */
337 func(); 335 func();
@@ -395,7 +393,6 @@ int trace_selftest_startup_dynamic_tracing(struct tracer *trace,
395 393
396 out: 394 out:
397 ftrace_enabled = save_ftrace_enabled; 395 ftrace_enabled = save_ftrace_enabled;
398 tracer_enabled = save_tracer_enabled;
399 396
400 /* Enable tracing on all functions again */ 397 /* Enable tracing on all functions again */
401 ftrace_set_global_filter(NULL, 0, 1); 398 ftrace_set_global_filter(NULL, 0, 1);
@@ -452,7 +449,6 @@ static int
452trace_selftest_function_recursion(void) 449trace_selftest_function_recursion(void)
453{ 450{
454 int save_ftrace_enabled = ftrace_enabled; 451 int save_ftrace_enabled = ftrace_enabled;
455 int save_tracer_enabled = tracer_enabled;
456 char *func_name; 452 char *func_name;
457 int len; 453 int len;
458 int ret; 454 int ret;
@@ -465,7 +461,6 @@ trace_selftest_function_recursion(void)
465 461
466 /* enable tracing, and record the filter function */ 462 /* enable tracing, and record the filter function */
467 ftrace_enabled = 1; 463 ftrace_enabled = 1;
468 tracer_enabled = 1;
469 464
470 /* Handle PPC64 '.' name */ 465 /* Handle PPC64 '.' name */
471 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME); 466 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
@@ -534,7 +529,6 @@ trace_selftest_function_recursion(void)
534 ret = 0; 529 ret = 0;
535out: 530out:
536 ftrace_enabled = save_ftrace_enabled; 531 ftrace_enabled = save_ftrace_enabled;
537 tracer_enabled = save_tracer_enabled;
538 532
539 return ret; 533 return ret;
540} 534}
@@ -569,7 +563,6 @@ static int
569trace_selftest_function_regs(void) 563trace_selftest_function_regs(void)
570{ 564{
571 int save_ftrace_enabled = ftrace_enabled; 565 int save_ftrace_enabled = ftrace_enabled;
572 int save_tracer_enabled = tracer_enabled;
573 char *func_name; 566 char *func_name;
574 int len; 567 int len;
575 int ret; 568 int ret;
@@ -586,7 +579,6 @@ trace_selftest_function_regs(void)
586 579
587 /* enable tracing, and record the filter function */ 580 /* enable tracing, and record the filter function */
588 ftrace_enabled = 1; 581 ftrace_enabled = 1;
589 tracer_enabled = 1;
590 582
591 /* Handle PPC64 '.' name */ 583 /* Handle PPC64 '.' name */
592 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME); 584 func_name = "*" __stringify(DYN_FTRACE_TEST_NAME);
@@ -648,7 +640,6 @@ trace_selftest_function_regs(void)
648 ret = 0; 640 ret = 0;
649out: 641out:
650 ftrace_enabled = save_ftrace_enabled; 642 ftrace_enabled = save_ftrace_enabled;
651 tracer_enabled = save_tracer_enabled;
652 643
653 return ret; 644 return ret;
654} 645}
@@ -662,7 +653,6 @@ int
662trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr) 653trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
663{ 654{
664 int save_ftrace_enabled = ftrace_enabled; 655 int save_ftrace_enabled = ftrace_enabled;
665 int save_tracer_enabled = tracer_enabled;
666 unsigned long count; 656 unsigned long count;
667 int ret; 657 int ret;
668 658
@@ -671,7 +661,6 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
671 661
672 /* start the tracing */ 662 /* start the tracing */
673 ftrace_enabled = 1; 663 ftrace_enabled = 1;
674 tracer_enabled = 1;
675 664
676 ret = tracer_init(trace, tr); 665 ret = tracer_init(trace, tr);
677 if (ret) { 666 if (ret) {
@@ -708,7 +697,6 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
708 ret = trace_selftest_function_regs(); 697 ret = trace_selftest_function_regs();
709 out: 698 out:
710 ftrace_enabled = save_ftrace_enabled; 699 ftrace_enabled = save_ftrace_enabled;
711 tracer_enabled = save_tracer_enabled;
712 700
713 /* kill ftrace totally if we failed */ 701 /* kill ftrace totally if we failed */
714 if (ret) 702 if (ret)