提交 43a15386 编写于 作者: F Frédéric Weisbecker 提交者: Ingo Molnar

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: NFrederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Steven Noonan <steven@uplinklabs.net>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 2a3a4f66
...@@ -142,24 +142,6 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait); ...@@ -142,24 +142,6 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
/* trace_flags holds iter_ctrl options */ /* trace_flags holds iter_ctrl options */
unsigned long trace_flags = TRACE_ITER_PRINT_PARENT; unsigned long trace_flags = TRACE_ITER_PRINT_PARENT;
static notrace void no_trace_init(struct trace_array *tr)
{
int cpu;
ftrace_function_enabled = 0;
if(tr->ctrl)
for_each_online_cpu(cpu)
tracing_reset(tr->data[cpu]);
tracer_enabled = 0;
}
/* dummy trace to disable tracing */
static struct tracer no_tracer __read_mostly = {
.name = "none",
.init = no_trace_init
};
/** /**
* trace_wake_up - wake up tasks waiting for trace input * trace_wake_up - wake up tasks waiting for trace input
* *
...@@ -962,7 +944,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) ...@@ -962,7 +944,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
long disabled; long disabled;
int cpu; int cpu;
if (tracing_disabled || current_trace == &no_tracer || !tr->ctrl) if (tracing_disabled || !tr->ctrl)
return; return;
local_irq_save(flags); local_irq_save(flags);
...@@ -2795,6 +2777,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, ...@@ -2795,6 +2777,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
unsigned long val; unsigned long val;
char buf[64]; char buf[64];
int i, ret; int i, ret;
struct trace_array *tr = filp->private_data;
if (cnt >= sizeof(buf)) if (cnt >= sizeof(buf))
return -EINVAL; return -EINVAL;
...@@ -2814,9 +2797,9 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, ...@@ -2814,9 +2797,9 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
mutex_lock(&trace_types_lock); mutex_lock(&trace_types_lock);
if (current_trace != &no_tracer) { if (tr->ctrl) {
cnt = -EBUSY; cnt = -EBUSY;
pr_info("ftrace: set current_tracer to none" pr_info("ftrace: please disable tracing"
" before modifying buffer size\n"); " before modifying buffer size\n");
goto out; goto out;
} }
...@@ -2879,20 +2862,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, ...@@ -2879,20 +2862,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
return cnt; return cnt;
} }
static int tracing_open_mark(struct inode *inode, struct file *filp)
{
int ret;
ret = tracing_open_generic(inode, filp);
if (ret)
return ret;
if (current_trace == &no_tracer)
return -ENODEV;
return 0;
}
static int mark_printk(const char *fmt, ...) static int mark_printk(const char *fmt, ...)
{ {
int ret; int ret;
...@@ -2911,7 +2880,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, ...@@ -2911,7 +2880,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
char *end; char *end;
struct trace_array *tr = &global_trace; struct trace_array *tr = &global_trace;
if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled) if (!tr->ctrl || tracing_disabled)
return -EINVAL; return -EINVAL;
if (cnt > TRACE_BUF_SIZE) if (cnt > TRACE_BUF_SIZE)
...@@ -2971,7 +2940,7 @@ static struct file_operations tracing_entries_fops = { ...@@ -2971,7 +2940,7 @@ static struct file_operations tracing_entries_fops = {
}; };
static struct file_operations tracing_mark_fops = { static struct file_operations tracing_mark_fops = {
.open = tracing_open_mark, .open = tracing_open_generic,
.write = tracing_mark_write, .write = tracing_mark_write,
}; };
...@@ -3123,7 +3092,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args) ...@@ -3123,7 +3092,7 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
long disabled; long disabled;
int cpu, len = 0, write, written = 0; int cpu, len = 0, write, written = 0;
if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled) if (!tr->ctrl || tracing_disabled)
return 0; return 0;
local_irq_save(flags); local_irq_save(flags);
...@@ -3539,8 +3508,8 @@ __init static int tracer_alloc_buffers(void) ...@@ -3539,8 +3508,8 @@ __init static int tracer_alloc_buffers(void)
trace_init_cmdlines(); trace_init_cmdlines();
register_tracer(&no_tracer); register_tracer(&nop_trace);
current_trace = &no_tracer; current_trace = &nop_trace;
/* All seems OK, enable tracing */ /* All seems OK, enable tracing */
global_trace.ctrl = tracer_enabled; global_trace.ctrl = tracer_enabled;
......
...@@ -369,4 +369,6 @@ enum trace_iterator_flags { ...@@ -369,4 +369,6 @@ enum trace_iterator_flags {
TRACE_ITER_PRINTK = 0x400, TRACE_ITER_PRINTK = 0x400,
}; };
extern struct tracer nop_trace;
#endif /* _LINUX_KERNEL_TRACE_H */ #endif /* _LINUX_KERNEL_TRACE_H */
...@@ -51,7 +51,7 @@ static void nop_trace_ctrl_update(struct trace_array *tr) ...@@ -51,7 +51,7 @@ static void nop_trace_ctrl_update(struct trace_array *tr)
stop_nop_trace(tr); stop_nop_trace(tr);
} }
static struct tracer nop_trace __read_mostly = struct tracer nop_trace __read_mostly =
{ {
.name = "nop", .name = "nop",
.init = nop_trace_init, .init = nop_trace_init,
...@@ -62,8 +62,3 @@ static struct tracer nop_trace __read_mostly = ...@@ -62,8 +62,3 @@ static struct tracer nop_trace __read_mostly =
#endif #endif
}; };
__init static int init_nop_trace(void)
{
return register_tracer(&nop_trace);
}
device_initcall(init_nop_trace);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册