aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-05 04:21:49 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-05 04:21:49 -0500
commit53664738c122bfe8b0e489fddaf2ab265c9133c8 (patch)
tree8121a9fc4021e86499c404e0b1012a36e8d0b00e /kernel/trace/trace.c
parentc4ef144a9d0803eb0a2d4110ae87e7f34e667ded (diff)
parente9d25fe6eaa2c720bb3ea661b660e58d54fa38bf (diff)
Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c83
1 files changed, 25 insertions, 58 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c8abbb0c8397..d1ef43999d9e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -299,6 +299,7 @@ static const char *trace_options[] = {
299 "sym-userobj", 299 "sym-userobj",
300 "printk-msg-only", 300 "printk-msg-only",
301 "context-info", 301 "context-info",
302 "latency-format",
302 NULL 303 NULL
303}; 304};
304 305
@@ -346,6 +347,9 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
346 int len; 347 int len;
347 int ret; 348 int ret;
348 349
350 if (!cnt)
351 return 0;
352
349 if (s->len <= s->readpos) 353 if (s->len <= s->readpos)
350 return -EBUSY; 354 return -EBUSY;
351 355
@@ -353,10 +357,12 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
353 if (cnt > len) 357 if (cnt > len)
354 cnt = len; 358 cnt = len;
355 ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); 359 ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
356 if (ret) 360 if (ret == cnt)
357 return -EFAULT; 361 return -EFAULT;
358 362
359 s->readpos += len; 363 cnt -= ret;
364
365 s->readpos += cnt;
360 return cnt; 366 return cnt;
361} 367}
362 368
@@ -375,7 +381,7 @@ ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
375 if (!ret) 381 if (!ret)
376 return -EFAULT; 382 return -EFAULT;
377 383
378 s->readpos += len; 384 s->readpos += cnt;
379 return cnt; 385 return cnt;
380} 386}
381 387
@@ -1462,33 +1468,6 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
1462 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu); 1468 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu);
1463} 1469}
1464 1470
1465static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
1466{
1467 struct trace_seq *s = &iter->seq;
1468 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
1469 struct trace_event *event;
1470 struct trace_entry *entry = iter->ent;
1471
1472 test_cpu_buff_start(iter);
1473
1474 event = ftrace_find_event(entry->type);
1475
1476 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1477 if (!trace_print_lat_context(iter))
1478 goto partial;
1479 }
1480
1481 if (event)
1482 return event->latency_trace(iter, sym_flags);
1483
1484 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
1485 goto partial;
1486
1487 return TRACE_TYPE_HANDLED;
1488partial:
1489 return TRACE_TYPE_PARTIAL_LINE;
1490}
1491
1492static enum print_line_t print_trace_fmt(struct trace_iterator *iter) 1471static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1493{ 1472{
1494 struct trace_seq *s = &iter->seq; 1473 struct trace_seq *s = &iter->seq;
@@ -1503,8 +1482,13 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1503 event = ftrace_find_event(entry->type); 1482 event = ftrace_find_event(entry->type);
1504 1483
1505 if (trace_flags & TRACE_ITER_CONTEXT_INFO) { 1484 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1506 if (!trace_print_context(iter)) 1485 if (iter->iter_flags & TRACE_FILE_LAT_FMT) {
1507 goto partial; 1486 if (!trace_print_lat_context(iter))
1487 goto partial;
1488 } else {
1489 if (!trace_print_context(iter))
1490 goto partial;
1491 }
1508 } 1492 }
1509 1493
1510 if (event) 1494 if (event)
@@ -1646,9 +1630,6 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
1646 if (trace_flags & TRACE_ITER_RAW) 1630 if (trace_flags & TRACE_ITER_RAW)
1647 return print_raw_fmt(iter); 1631 return print_raw_fmt(iter);
1648 1632
1649 if (iter->iter_flags & TRACE_FILE_LAT_FMT)
1650 return print_lat_fmt(iter);
1651
1652 return print_trace_fmt(iter); 1633 return print_trace_fmt(iter);
1653} 1634}
1654 1635
@@ -1824,26 +1805,12 @@ static int tracing_open(struct inode *inode, struct file *file)
1824 iter = __tracing_open(inode, file); 1805 iter = __tracing_open(inode, file);
1825 if (IS_ERR(iter)) 1806 if (IS_ERR(iter))
1826 ret = PTR_ERR(iter); 1807 ret = PTR_ERR(iter);
1827 1808 else if (trace_flags & TRACE_ITER_LATENCY_FMT)
1828 return ret;
1829}
1830
1831static int tracing_lt_open(struct inode *inode, struct file *file)
1832{
1833 struct trace_iterator *iter;
1834 int ret = 0;
1835
1836 iter = __tracing_open(inode, file);
1837
1838 if (IS_ERR(iter))
1839 ret = PTR_ERR(iter);
1840 else
1841 iter->iter_flags |= TRACE_FILE_LAT_FMT; 1809 iter->iter_flags |= TRACE_FILE_LAT_FMT;
1842 1810
1843 return ret; 1811 return ret;
1844} 1812}
1845 1813
1846
1847static void * 1814static void *
1848t_next(struct seq_file *m, void *v, loff_t *pos) 1815t_next(struct seq_file *m, void *v, loff_t *pos)
1849{ 1816{
@@ -1922,13 +1889,6 @@ static struct file_operations tracing_fops = {
1922 .release = tracing_release, 1889 .release = tracing_release,
1923}; 1890};
1924 1891
1925static struct file_operations tracing_lt_fops = {
1926 .open = tracing_lt_open,
1927 .read = seq_read,
1928 .llseek = seq_lseek,
1929 .release = tracing_release,
1930};
1931
1932static struct file_operations show_traces_fops = { 1892static struct file_operations show_traces_fops = {
1933 .open = show_traces_open, 1893 .open = show_traces_open,
1934 .read = seq_read, 1894 .read = seq_read,
@@ -3049,6 +3009,9 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
3049 ssize_t ret; 3009 ssize_t ret;
3050 size_t size; 3010 size_t size;
3051 3011
3012 if (!count)
3013 return 0;
3014
3052 /* Do we have previous read data to read? */ 3015 /* Do we have previous read data to read? */
3053 if (info->read < PAGE_SIZE) 3016 if (info->read < PAGE_SIZE)
3054 goto read; 3017 goto read;
@@ -3073,8 +3036,10 @@ read:
3073 size = count; 3036 size = count;
3074 3037
3075 ret = copy_to_user(ubuf, info->spare + info->read, size); 3038 ret = copy_to_user(ubuf, info->spare + info->read, size);
3076 if (ret) 3039 if (ret == size)
3077 return -EFAULT; 3040 return -EFAULT;
3041 size -= ret;
3042
3078 *ppos += size; 3043 *ppos += size;
3079 info->read += size; 3044 info->read += size;
3080 3045
@@ -3918,8 +3883,10 @@ void ftrace_dump(void)
3918 3883
3919 printk(KERN_TRACE "Dumping ftrace buffer:\n"); 3884 printk(KERN_TRACE "Dumping ftrace buffer:\n");
3920 3885
3886 /* Simulate the iterator */
3921 iter.tr = &global_trace; 3887 iter.tr = &global_trace;
3922 iter.trace = current_trace; 3888 iter.trace = current_trace;
3889 iter.cpu_file = TRACE_PIPE_ALL_CPU;
3923 3890
3924 /* 3891 /*
3925 * We need to stop all tracing on all CPUS to read the 3892 * We need to stop all tracing on all CPUS to read the