Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace

This commit is contained in:
Ingo Molnar 2009-03-05 10:21:49 +01:00
commit 53664738c1
9 changed files with 48 additions and 95 deletions

View File

@ -1231,7 +1231,6 @@ static struct tracer blk_tracer __read_mostly = {
static struct trace_event trace_blk_event = { static struct trace_event trace_blk_event = {
.type = TRACE_BLK, .type = TRACE_BLK,
.trace = blk_trace_event_print, .trace = blk_trace_event_print,
.latency_trace = blk_trace_event_print,
.binary = blk_trace_event_print_binary, .binary = blk_trace_event_print_binary,
}; };

View File

@ -2461,6 +2461,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
unsigned long flags; unsigned long flags;
unsigned int commit; unsigned int commit;
unsigned int read; unsigned int read;
u64 save_timestamp;
int ret = -1; int ret = -1;
/* /*
@ -2515,6 +2516,9 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
if (len < size) if (len < size)
goto out; goto out;
/* save the current timestamp, since the user will need it */
save_timestamp = cpu_buffer->read_stamp;
/* Need to copy one event at a time */ /* Need to copy one event at a time */
do { do {
memcpy(bpage->data + pos, rpage->data + rpos, size); memcpy(bpage->data + pos, rpage->data + rpos, size);
@ -2531,7 +2535,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
/* update bpage */ /* update bpage */
local_set(&bpage->commit, pos); local_set(&bpage->commit, pos);
bpage->time_stamp = rpage->time_stamp; bpage->time_stamp = save_timestamp;
/* we copied everything to the beginning */ /* we copied everything to the beginning */
read = 0; read = 0;

View File

@ -299,6 +299,7 @@ static const char *trace_options[] = {
"sym-userobj", "sym-userobj",
"printk-msg-only", "printk-msg-only",
"context-info", "context-info",
"latency-format",
NULL NULL
}; };
@ -346,6 +347,9 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
int len; int len;
int ret; int ret;
if (!cnt)
return 0;
if (s->len <= s->readpos) if (s->len <= s->readpos)
return -EBUSY; return -EBUSY;
@ -353,10 +357,12 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
if (cnt > len) if (cnt > len)
cnt = len; cnt = len;
ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
if (ret) if (ret == cnt)
return -EFAULT; return -EFAULT;
s->readpos += len; cnt -= ret;
s->readpos += cnt;
return cnt; return cnt;
} }
@ -375,7 +381,7 @@ ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
if (!ret) if (!ret)
return -EFAULT; return -EFAULT;
s->readpos += len; s->readpos += cnt;
return cnt; return cnt;
} }
@ -1462,33 +1468,6 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu); trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu);
} }
static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
{
struct trace_seq *s = &iter->seq;
unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
struct trace_event *event;
struct trace_entry *entry = iter->ent;
test_cpu_buff_start(iter);
event = ftrace_find_event(entry->type);
if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
if (!trace_print_lat_context(iter))
goto partial;
}
if (event)
return event->latency_trace(iter, sym_flags);
if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
goto partial;
return TRACE_TYPE_HANDLED;
partial:
return TRACE_TYPE_PARTIAL_LINE;
}
static enum print_line_t print_trace_fmt(struct trace_iterator *iter) static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
{ {
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
@ -1503,8 +1482,13 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type); event = ftrace_find_event(entry->type);
if (trace_flags & TRACE_ITER_CONTEXT_INFO) { if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
if (!trace_print_context(iter)) if (iter->iter_flags & TRACE_FILE_LAT_FMT) {
goto partial; if (!trace_print_lat_context(iter))
goto partial;
} else {
if (!trace_print_context(iter))
goto partial;
}
} }
if (event) if (event)
@ -1646,9 +1630,6 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
if (trace_flags & TRACE_ITER_RAW) if (trace_flags & TRACE_ITER_RAW)
return print_raw_fmt(iter); return print_raw_fmt(iter);
if (iter->iter_flags & TRACE_FILE_LAT_FMT)
return print_lat_fmt(iter);
return print_trace_fmt(iter); return print_trace_fmt(iter);
} }
@ -1824,26 +1805,12 @@ static int tracing_open(struct inode *inode, struct file *file)
iter = __tracing_open(inode, file); iter = __tracing_open(inode, file);
if (IS_ERR(iter)) if (IS_ERR(iter))
ret = PTR_ERR(iter); ret = PTR_ERR(iter);
else if (trace_flags & TRACE_ITER_LATENCY_FMT)
return ret;
}
static int tracing_lt_open(struct inode *inode, struct file *file)
{
struct trace_iterator *iter;
int ret = 0;
iter = __tracing_open(inode, file);
if (IS_ERR(iter))
ret = PTR_ERR(iter);
else
iter->iter_flags |= TRACE_FILE_LAT_FMT; iter->iter_flags |= TRACE_FILE_LAT_FMT;
return ret; return ret;
} }
static void * static void *
t_next(struct seq_file *m, void *v, loff_t *pos) t_next(struct seq_file *m, void *v, loff_t *pos)
{ {
@ -1922,13 +1889,6 @@ static struct file_operations tracing_fops = {
.release = tracing_release, .release = tracing_release,
}; };
static struct file_operations tracing_lt_fops = {
.open = tracing_lt_open,
.read = seq_read,
.llseek = seq_lseek,
.release = tracing_release,
};
static struct file_operations show_traces_fops = { static struct file_operations show_traces_fops = {
.open = show_traces_open, .open = show_traces_open,
.read = seq_read, .read = seq_read,
@ -3049,6 +3009,9 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
ssize_t ret; ssize_t ret;
size_t size; size_t size;
if (!count)
return 0;
/* Do we have previous read data to read? */ /* Do we have previous read data to read? */
if (info->read < PAGE_SIZE) if (info->read < PAGE_SIZE)
goto read; goto read;
@ -3073,8 +3036,10 @@ read:
size = count; size = count;
ret = copy_to_user(ubuf, info->spare + info->read, size); ret = copy_to_user(ubuf, info->spare + info->read, size);
if (ret) if (ret == size)
return -EFAULT; return -EFAULT;
size -= ret;
*ppos += size; *ppos += size;
info->read += size; info->read += size;
@ -3918,8 +3883,10 @@ void ftrace_dump(void)
printk(KERN_TRACE "Dumping ftrace buffer:\n"); printk(KERN_TRACE "Dumping ftrace buffer:\n");
/* Simulate the iterator */
iter.tr = &global_trace; iter.tr = &global_trace;
iter.trace = current_trace; iter.trace = current_trace;
iter.cpu_file = TRACE_PIPE_ALL_CPU;
/* /*
* We need to stop all tracing on all CPUS to read the * We need to stop all tracing on all CPUS to read the

View File

@ -651,7 +651,8 @@ enum trace_iterator_flags {
TRACE_ITER_USERSTACKTRACE = 0x4000, TRACE_ITER_USERSTACKTRACE = 0x4000,
TRACE_ITER_SYM_USEROBJ = 0x8000, TRACE_ITER_SYM_USEROBJ = 0x8000,
TRACE_ITER_PRINTK_MSGONLY = 0x10000, TRACE_ITER_PRINTK_MSGONLY = 0x10000,
TRACE_ITER_CONTEXT_INFO = 0x20000 /* Print pid/cpu/time */ TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */
TRACE_ITER_LATENCY_FMT = 0x40000,
}; };
/* /*

View File

@ -159,7 +159,6 @@ static enum print_line_t trace_branch_print(struct trace_iterator *iter,
static struct trace_event trace_branch_event = { static struct trace_event trace_branch_event = {
.type = TRACE_BRANCH, .type = TRACE_BRANCH,
.trace = trace_branch_print, .trace = trace_branch_print,
.latency_trace = trace_branch_print,
}; };
static struct tracer branch_trace __read_mostly = static struct tracer branch_trace __read_mostly =

View File

@ -32,6 +32,8 @@ enum {
static int trace_type __read_mostly; static int trace_type __read_mostly;
static int save_lat_flag;
#ifdef CONFIG_PREEMPT_TRACER #ifdef CONFIG_PREEMPT_TRACER
static inline int static inline int
preempt_trace(void) preempt_trace(void)
@ -370,6 +372,9 @@ static void stop_irqsoff_tracer(struct trace_array *tr)
static void __irqsoff_tracer_init(struct trace_array *tr) static void __irqsoff_tracer_init(struct trace_array *tr)
{ {
save_lat_flag = trace_flags & TRACE_ITER_LATENCY_FMT;
trace_flags |= TRACE_ITER_LATENCY_FMT;
tracing_max_latency = 0; tracing_max_latency = 0;
irqsoff_trace = tr; irqsoff_trace = tr;
/* make sure that the tracer is visible */ /* make sure that the tracer is visible */
@ -380,6 +385,9 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
static void irqsoff_tracer_reset(struct trace_array *tr) static void irqsoff_tracer_reset(struct trace_array *tr)
{ {
stop_irqsoff_tracer(tr); stop_irqsoff_tracer(tr);
if (!save_lat_flag)
trace_flags &= ~TRACE_ITER_LATENCY_FMT;
} }
static void irqsoff_tracer_start(struct trace_array *tr) static void irqsoff_tracer_start(struct trace_array *tr)

View File

@ -437,8 +437,6 @@ int register_ftrace_event(struct trace_event *event)
if (event->trace == NULL) if (event->trace == NULL)
event->trace = trace_nop_print; event->trace = trace_nop_print;
if (event->latency_trace == NULL)
event->latency_trace = trace_nop_print;
if (event->raw == NULL) if (event->raw == NULL)
event->raw = trace_nop_print; event->raw = trace_nop_print;
if (event->hex == NULL) if (event->hex == NULL)
@ -480,29 +478,6 @@ enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags)
} }
/* TRACE_FN */ /* TRACE_FN */
static enum print_line_t trace_fn_latency(struct trace_iterator *iter,
int flags)
{
struct ftrace_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
if (!seq_print_ip_sym(s, field->ip, flags))
goto partial;
if (!trace_seq_puts(s, " ("))
goto partial;
if (!seq_print_ip_sym(s, field->parent_ip, flags))
goto partial;
if (!trace_seq_puts(s, ")\n"))
goto partial;
return TRACE_TYPE_HANDLED;
partial:
return TRACE_TYPE_PARTIAL_LINE;
}
static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags) static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
@ -573,7 +548,6 @@ static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags)
static struct trace_event trace_fn_event = { static struct trace_event trace_fn_event = {
.type = TRACE_FN, .type = TRACE_FN,
.trace = trace_fn_trace, .trace = trace_fn_trace,
.latency_trace = trace_fn_latency,
.raw = trace_fn_raw, .raw = trace_fn_raw,
.hex = trace_fn_hex, .hex = trace_fn_hex,
.binary = trace_fn_bin, .binary = trace_fn_bin,
@ -705,7 +679,6 @@ static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
static struct trace_event trace_ctx_event = { static struct trace_event trace_ctx_event = {
.type = TRACE_CTX, .type = TRACE_CTX,
.trace = trace_ctx_print, .trace = trace_ctx_print,
.latency_trace = trace_ctx_print,
.raw = trace_ctx_raw, .raw = trace_ctx_raw,
.hex = trace_ctx_hex, .hex = trace_ctx_hex,
.binary = trace_ctxwake_bin, .binary = trace_ctxwake_bin,
@ -714,7 +687,6 @@ static struct trace_event trace_ctx_event = {
static struct trace_event trace_wake_event = { static struct trace_event trace_wake_event = {
.type = TRACE_WAKE, .type = TRACE_WAKE,
.trace = trace_wake_print, .trace = trace_wake_print,
.latency_trace = trace_wake_print,
.raw = trace_wake_raw, .raw = trace_wake_raw,
.hex = trace_wake_hex, .hex = trace_wake_hex,
.binary = trace_ctxwake_bin, .binary = trace_ctxwake_bin,
@ -770,7 +742,6 @@ static enum print_line_t trace_special_bin(struct trace_iterator *iter,
static struct trace_event trace_special_event = { static struct trace_event trace_special_event = {
.type = TRACE_SPECIAL, .type = TRACE_SPECIAL,
.trace = trace_special_print, .trace = trace_special_print,
.latency_trace = trace_special_print,
.raw = trace_special_print, .raw = trace_special_print,
.hex = trace_special_hex, .hex = trace_special_hex,
.binary = trace_special_bin, .binary = trace_special_bin,
@ -808,7 +779,6 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
static struct trace_event trace_stack_event = { static struct trace_event trace_stack_event = {
.type = TRACE_STACK, .type = TRACE_STACK,
.trace = trace_stack_print, .trace = trace_stack_print,
.latency_trace = trace_stack_print,
.raw = trace_special_print, .raw = trace_special_print,
.hex = trace_special_hex, .hex = trace_special_hex,
.binary = trace_special_bin, .binary = trace_special_bin,
@ -838,7 +808,6 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
static struct trace_event trace_user_stack_event = { static struct trace_event trace_user_stack_event = {
.type = TRACE_USER_STACK, .type = TRACE_USER_STACK,
.trace = trace_user_stack_print, .trace = trace_user_stack_print,
.latency_trace = trace_user_stack_print,
.raw = trace_special_print, .raw = trace_special_print,
.hex = trace_special_hex, .hex = trace_special_hex,
.binary = trace_special_bin, .binary = trace_special_bin,
@ -883,7 +852,6 @@ static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags)
static struct trace_event trace_print_event = { static struct trace_event trace_print_event = {
.type = TRACE_PRINT, .type = TRACE_PRINT,
.trace = trace_print_print, .trace = trace_print_print,
.latency_trace = trace_print_print,
.raw = trace_print_raw, .raw = trace_print_raw,
}; };

View File

@ -10,7 +10,6 @@ struct trace_event {
struct hlist_node node; struct hlist_node node;
int type; int type;
trace_print_func trace; trace_print_func trace;
trace_print_func latency_trace;
trace_print_func raw; trace_print_func raw;
trace_print_func hex; trace_print_func hex;
trace_print_func binary; trace_print_func binary;

View File

@ -32,6 +32,8 @@ static raw_spinlock_t wakeup_lock =
static void __wakeup_reset(struct trace_array *tr); static void __wakeup_reset(struct trace_array *tr);
static int save_lat_flag;
#ifdef CONFIG_FUNCTION_TRACER #ifdef CONFIG_FUNCTION_TRACER
/* /*
* irqsoff uses its own tracer function to keep the overhead down: * irqsoff uses its own tracer function to keep the overhead down:
@ -324,6 +326,9 @@ static void stop_wakeup_tracer(struct trace_array *tr)
static int __wakeup_tracer_init(struct trace_array *tr) static int __wakeup_tracer_init(struct trace_array *tr)
{ {
save_lat_flag = trace_flags & TRACE_ITER_LATENCY_FMT;
trace_flags |= TRACE_ITER_LATENCY_FMT;
tracing_max_latency = 0; tracing_max_latency = 0;
wakeup_trace = tr; wakeup_trace = tr;
start_wakeup_tracer(tr); start_wakeup_tracer(tr);
@ -347,6 +352,9 @@ static void wakeup_tracer_reset(struct trace_array *tr)
stop_wakeup_tracer(tr); stop_wakeup_tracer(tr);
/* make sure we put back any tasks we are tracing */ /* make sure we put back any tasks we are tracing */
wakeup_reset(tr); wakeup_reset(tr);
if (!save_lat_flag)
trace_flags &= ~TRACE_ITER_LATENCY_FMT;
} }
static void wakeup_tracer_start(struct trace_array *tr) static void wakeup_tracer_start(struct trace_array *tr)