Commit 801fe400 authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Ingo Molnar

ftrace: add trace_vprintk()

trace_vprintk() for easier implementation of tracer specific *_printk
functions. Add check check for no_tracer, and implement
__ftrace_printk() as a wrapper.
Signed-off-by: default avatarPekka Paalanen <pq@iki.fi>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 45dcd8b8
...@@ -3054,7 +3054,7 @@ static __init void tracer_init_debugfs(void) ...@@ -3054,7 +3054,7 @@ static __init void tracer_init_debugfs(void)
(sizeof(struct trace_field) - offsetof(struct trace_field, print.buf)) (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf))
#define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) #define TRACE_CONT_BUF_SIZE sizeof(struct trace_field)
int __ftrace_printk(unsigned long ip, const char *fmt, ...) int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
{ {
static DEFINE_SPINLOCK(trace_buf_lock); static DEFINE_SPINLOCK(trace_buf_lock);
static char trace_buf[TRACE_BUF_SIZE]; static char trace_buf[TRACE_BUF_SIZE];
...@@ -3064,10 +3064,9 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) ...@@ -3064,10 +3064,9 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...)
struct trace_entry *entry; struct trace_entry *entry;
unsigned long flags; unsigned long flags;
long disabled; long disabled;
va_list ap;
int cpu, len = 0, write, written = 0; int cpu, len = 0, write, written = 0;
if (!(trace_flags & TRACE_ITER_PRINTK) || !tr->ctrl || tracing_disabled) if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled)
return 0; return 0;
local_irq_save(flags); local_irq_save(flags);
...@@ -3079,9 +3078,7 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) ...@@ -3079,9 +3078,7 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...)
goto out; goto out;
spin_lock(&trace_buf_lock); spin_lock(&trace_buf_lock);
va_start(ap, fmt); len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, ap);
va_end(ap);
len = min(len, TRACE_BUF_SIZE-1); len = min(len, TRACE_BUF_SIZE-1);
trace_buf[len] = 0; trace_buf[len] = 0;
...@@ -3120,6 +3117,21 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) ...@@ -3120,6 +3117,21 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...)
return len; return len;
} }
EXPORT_SYMBOL_GPL(trace_vprintk);
int __ftrace_printk(unsigned long ip, const char *fmt, ...)
{
int ret;
va_list ap;
if (!(trace_flags & TRACE_ITER_PRINTK))
return 0;
va_start(ap, fmt);
ret = trace_vprintk(ip, fmt, ap);
va_end(ap);
return ret;
}
EXPORT_SYMBOL_GPL(__ftrace_printk); EXPORT_SYMBOL_GPL(__ftrace_printk);
static int trace_panic_handler(struct notifier_block *this, static int trace_panic_handler(struct notifier_block *this,
......
...@@ -333,6 +333,7 @@ extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); ...@@ -333,6 +333,7 @@ extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
size_t cnt); size_t cnt);
extern long ns2usecs(cycle_t nsec); extern long ns2usecs(cycle_t nsec);
extern int trace_vprintk(unsigned long ip, const char *fmt, va_list args);
extern unsigned long trace_flags; extern unsigned long trace_flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment