aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Weisbecker <fweisbec@gmail.com>2008-09-21 14:16:30 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:38:09 -0400
commit43a15386c4faf913f7d70a47748c266d6210cd6e (patch)
tree2af766a34661123bd520fb30b1f83fbff1e65dab
parent2a3a4f669df2164288d11406d11d5e4933bf5e53 (diff)
tracing/ftrace: replace none tracer by nop tracer
Replace "none" tracer by the recently created "nop" tracer. Both are pretty similar except that nop accepts TRACE_PRINT or TRACE_SPECIAL entries. And as a consequence, changing the size of the ring buffer now requires that tracing has already been disabled. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Steven Noonan <steven@uplinklabs.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/trace/trace.c49
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_nop.c7
3 files changed, 12 insertions, 46 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index eee1fd964898..f2ef72fa3f17 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -142,24 +142,6 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
142/* trace_flags holds iter_ctrl options */ 142/* trace_flags holds iter_ctrl options */
143unsigned long trace_flags = TRACE_ITER_PRINT_PARENT; 143unsigned long trace_flags = TRACE_ITER_PRINT_PARENT;
144 144
145static notrace void no_trace_init(struct trace_array *tr)
146{
147 int cpu;
148
149 ftrace_function_enabled = 0;
150 if(tr->ctrl)
151 for_each_online_cpu(cpu)
152 tracing_reset(tr->data[cpu]);
153 tracer_enabled = 0;
154}
155
156/* dummy trace to disable tracing */
157static struct tracer no_tracer __read_mostly = {
158 .name = "none",
159 .init = no_trace_init
160};
161
162
163/** 145/**
164 * trace_wake_up - wake up tasks waiting for trace input 146 * trace_wake_up - wake up tasks waiting for trace input
165 * 147 *
@@ -962,7 +944,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
962 long disabled; 944 long disabled;
963 int cpu; 945 int cpu;
964 946
965 if (tracing_disabled || current_trace == &no_tracer || !tr->ctrl) 947 if (tracing_disabled || !tr->ctrl)
966 return; 948 return;
967 949
968 local_irq_save(flags); 950 local_irq_save(flags);
@@ -2795,6 +2777,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2795 unsigned long val; 2777 unsigned long val;
2796 char buf[64]; 2778 char buf[64];
2797 int i, ret; 2779 int i, ret;
2780 struct trace_array *tr = filp->private_data;
2798 2781
2799 if (cnt >= sizeof(buf)) 2782 if (cnt >= sizeof(buf))
2800 return -EINVAL; 2783 return -EINVAL;
@@ -2814,9 +2797,9 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2814 2797
2815 mutex_lock(&trace_types_lock); 2798 mutex_lock(&trace_types_lock);
2816 2799
2817 if (current_trace != &no_tracer) { 2800 if (tr->ctrl) {
2818 cnt = -EBUSY; 2801 cnt = -EBUSY;
2819 pr_info("ftrace: set current_tracer to none" 2802 pr_info("ftrace: please disable tracing"
2820 " before modifying buffer size\n"); 2803 " before modifying buffer size\n");
2821 goto out; 2804 goto out;
2822 } 2805 }
@@ -2879,20 +2862,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
2879 return cnt; 2862 return cnt;
2880} 2863}
2881 2864
2882static int tracing_open_mark(struct inode *inode, struct file *filp)
2883{
2884 int ret;
2885
2886 ret = tracing_open_generic(inode, filp);
2887 if (ret)
2888 return ret;
2889
2890 if (current_trace == &no_tracer)
2891 return -ENODEV;
2892
2893 return 0;
2894}
2895
2896static int mark_printk(const char *fmt, ...) 2865static int mark_printk(const char *fmt, ...)
2897{ 2866{
2898 int ret; 2867 int ret;
@@ -2911,7 +2880,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
2911 char *end; 2880 char *end;
2912 struct trace_array *tr = &global_trace; 2881 struct trace_array *tr = &global_trace;
2913 2882
2914 if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled) 2883 if (!tr->ctrl || tracing_disabled)
2915 return -EINVAL; 2884 return -EINVAL;
2916 2885
2917 if (cnt > TRACE_BUF_SIZE) 2886 if (cnt > TRACE_BUF_SIZE)
@@ -2971,7 +2940,7 @@ static struct file_operations tracing_entries_fops = {
2971}; 2940};
2972 2941
2973static struct file_operations tracing_mark_fops = { 2942static struct file_operations tracing_mark_fops = {
2974 .open = tracing_open_mark, 2943 .open = tracing_open_generic,
2975 .write = tracing_mark_write, 2944 .write = tracing_mark_write,
2976}; 2945};
2977 2946
@@ -3123,7 +3092,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
3123 long disabled; 3092 long disabled;
3124 int cpu, len = 0, write, written = 0; 3093 int cpu, len = 0, write, written = 0;
3125 3094
3126 if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled) 3095 if (!tr->ctrl || tracing_disabled)
3127 return 0; 3096 return 0;
3128 3097
3129 local_irq_save(flags); 3098 local_irq_save(flags);
@@ -3539,8 +3508,8 @@ __init static int tracer_alloc_buffers(void)
3539 3508
3540 trace_init_cmdlines(); 3509 trace_init_cmdlines();
3541 3510
3542 register_tracer(&no_tracer); 3511 register_tracer(&nop_trace);
3543 current_trace = &no_tracer; 3512 current_trace = &nop_trace;
3544 3513
3545 /* All seems OK, enable tracing */ 3514 /* All seems OK, enable tracing */
3546 global_trace.ctrl = tracer_enabled; 3515 global_trace.ctrl = tracer_enabled;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index c8c687088b4d..cb2c3fb7dd54 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -369,4 +369,6 @@ enum trace_iterator_flags {
369 TRACE_ITER_PRINTK = 0x400, 369 TRACE_ITER_PRINTK = 0x400,
370}; 370};
371 371
372extern struct tracer nop_trace;
373
372#endif /* _LINUX_KERNEL_TRACE_H */ 374#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_nop.c b/kernel/trace/trace_nop.c
index 9fb02c17ad0c..16c9ba060bab 100644
--- a/kernel/trace/trace_nop.c
+++ b/kernel/trace/trace_nop.c
@@ -51,7 +51,7 @@ static void nop_trace_ctrl_update(struct trace_array *tr)
51 stop_nop_trace(tr); 51 stop_nop_trace(tr);
52} 52}
53 53
54static struct tracer nop_trace __read_mostly = 54struct tracer nop_trace __read_mostly =
55{ 55{
56 .name = "nop", 56 .name = "nop",
57 .init = nop_trace_init, 57 .init = nop_trace_init,
@@ -62,8 +62,3 @@ static struct tracer nop_trace __read_mostly =
62#endif 62#endif
63}; 63};
64 64
65__init static int init_nop_trace(void)
66{
67 return register_tracer(&nop_trace);
68}
69device_initcall(init_nop_trace);