diff options
author | Pekka Paalanen <pq@iki.fi> | 2008-09-16 14:58:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-14 04:37:07 -0400 |
commit | 801fe40001dfc263848552fb28924b766ed44ea4 (patch) | |
tree | fbb0a6ff09deb9f605d955ccdc6f5cb89793e1cf /kernel/trace | |
parent | 45dcd8b8a8ca855591e3ac882d3a7fc255d09d43 (diff) |
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: Pekka Paalanen <pq@iki.fi>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 24 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 |
2 files changed, 19 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index d372bc535963..406de9cf2820 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3054,7 +3054,7 @@ static __init void tracer_init_debugfs(void) | |||
3054 | (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf)) | 3054 | (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf)) |
3055 | #define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) | 3055 | #define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) |
3056 | 3056 | ||
3057 | int __ftrace_printk(unsigned long ip, const char *fmt, ...) | 3057 | int trace_vprintk(unsigned long ip, const char *fmt, va_list args) |
3058 | { | 3058 | { |
3059 | static DEFINE_SPINLOCK(trace_buf_lock); | 3059 | static DEFINE_SPINLOCK(trace_buf_lock); |
3060 | static char trace_buf[TRACE_BUF_SIZE]; | 3060 | static char trace_buf[TRACE_BUF_SIZE]; |
@@ -3064,10 +3064,9 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) | |||
3064 | struct trace_entry *entry; | 3064 | struct trace_entry *entry; |
3065 | unsigned long flags; | 3065 | unsigned long flags; |
3066 | long disabled; | 3066 | long disabled; |
3067 | va_list ap; | ||
3068 | int cpu, len = 0, write, written = 0; | 3067 | int cpu, len = 0, write, written = 0; |
3069 | 3068 | ||
3070 | if (!(trace_flags & TRACE_ITER_PRINTK) || !tr->ctrl || tracing_disabled) | 3069 | if (current_trace == &no_tracer || !tr->ctrl || tracing_disabled) |
3071 | return 0; | 3070 | return 0; |
3072 | 3071 | ||
3073 | local_irq_save(flags); | 3072 | local_irq_save(flags); |
@@ -3079,9 +3078,7 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) | |||
3079 | goto out; | 3078 | goto out; |
3080 | 3079 | ||
3081 | spin_lock(&trace_buf_lock); | 3080 | spin_lock(&trace_buf_lock); |
3082 | va_start(ap, fmt); | 3081 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); |
3083 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, ap); | ||
3084 | va_end(ap); | ||
3085 | 3082 | ||
3086 | len = min(len, TRACE_BUF_SIZE-1); | 3083 | len = min(len, TRACE_BUF_SIZE-1); |
3087 | trace_buf[len] = 0; | 3084 | trace_buf[len] = 0; |
@@ -3120,6 +3117,21 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...) | |||
3120 | 3117 | ||
3121 | return len; | 3118 | return len; |
3122 | } | 3119 | } |
3120 | EXPORT_SYMBOL_GPL(trace_vprintk); | ||
3121 | |||
3122 | int __ftrace_printk(unsigned long ip, const char *fmt, ...) | ||
3123 | { | ||
3124 | int ret; | ||
3125 | va_list ap; | ||
3126 | |||
3127 | if (!(trace_flags & TRACE_ITER_PRINTK)) | ||
3128 | return 0; | ||
3129 | |||
3130 | va_start(ap, fmt); | ||
3131 | ret = trace_vprintk(ip, fmt, ap); | ||
3132 | va_end(ap); | ||
3133 | return ret; | ||
3134 | } | ||
3123 | EXPORT_SYMBOL_GPL(__ftrace_printk); | 3135 | EXPORT_SYMBOL_GPL(__ftrace_printk); |
3124 | 3136 | ||
3125 | static int trace_panic_handler(struct notifier_block *this, | 3137 | static int trace_panic_handler(struct notifier_block *this, |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 9d39aa00a9c6..be3b3cf95f4b 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -333,6 +333,7 @@ extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); | |||
333 | extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | 333 | extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
334 | size_t cnt); | 334 | size_t cnt); |
335 | extern long ns2usecs(cycle_t nsec); | 335 | extern long ns2usecs(cycle_t nsec); |
336 | extern int trace_vprintk(unsigned long ip, const char *fmt, va_list args); | ||
336 | 337 | ||
337 | extern unsigned long trace_flags; | 338 | extern unsigned long trace_flags; |
338 | 339 | ||