aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-20 05:15:13 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-20 05:15:13 -0400
commit44fc6ee92356aa3be31798ced220ab5abd898781 (patch)
tree45acaa8fe5e620cbf734bdbeb5d48121daa65d0e /kernel/trace/trace.c
parent22de89b371a18086162eacd9f8c960299334ab01 (diff)
parent5087f8d2a2f2daff5a913d72d8ea3ad601948e10 (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.c85
1 files changed, 38 insertions, 47 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c95b7292be70..e3dfefe69348 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1201,7 +1201,7 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
1201 * trace_vbprintk - write binary msg to tracing buffer 1201 * trace_vbprintk - write binary msg to tracing buffer
1202 * 1202 *
1203 */ 1203 */
1204int trace_vbprintk(unsigned long ip, int depth, const char *fmt, va_list args) 1204int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
1205{ 1205{
1206 static raw_spinlock_t trace_buf_lock = 1206 static raw_spinlock_t trace_buf_lock =
1207 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; 1207 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
@@ -1243,7 +1243,6 @@ int trace_vbprintk(unsigned long ip, int depth, const char *fmt, va_list args)
1243 goto out_unlock; 1243 goto out_unlock;
1244 entry = ring_buffer_event_data(event); 1244 entry = ring_buffer_event_data(event);
1245 entry->ip = ip; 1245 entry->ip = ip;
1246 entry->depth = depth;
1247 entry->fmt = fmt; 1246 entry->fmt = fmt;
1248 1247
1249 memcpy(entry->buf, trace_buf, sizeof(u32) * len); 1248 memcpy(entry->buf, trace_buf, sizeof(u32) * len);
@@ -1261,7 +1260,7 @@ out:
1261} 1260}
1262EXPORT_SYMBOL_GPL(trace_vbprintk); 1261EXPORT_SYMBOL_GPL(trace_vbprintk);
1263 1262
1264int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) 1263int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
1265{ 1264{
1266 static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED; 1265 static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED;
1267 static char trace_buf[TRACE_BUF_SIZE]; 1266 static char trace_buf[TRACE_BUF_SIZE];
@@ -1298,7 +1297,6 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args)
1298 goto out_unlock; 1297 goto out_unlock;
1299 entry = ring_buffer_event_data(event); 1298 entry = ring_buffer_event_data(event);
1300 entry->ip = ip; 1299 entry->ip = ip;
1301 entry->depth = depth;
1302 1300
1303 memcpy(&entry->buf, trace_buf, len); 1301 memcpy(&entry->buf, trace_buf, len);
1304 entry->buf[len] = 0; 1302 entry->buf[len] = 0;
@@ -1701,38 +1699,6 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
1701 return TRACE_TYPE_HANDLED; 1699 return TRACE_TYPE_HANDLED;
1702} 1700}
1703 1701
1704static enum print_line_t print_bprintk_msg_only(struct trace_iterator *iter)
1705{
1706 struct trace_seq *s = &iter->seq;
1707 struct trace_entry *entry = iter->ent;
1708 struct bprint_entry *field;
1709 int ret;
1710
1711 trace_assign_type(field, entry);
1712
1713 ret = trace_seq_bprintf(s, field->fmt, field->buf);
1714 if (!ret)
1715 return TRACE_TYPE_PARTIAL_LINE;
1716
1717 return TRACE_TYPE_HANDLED;
1718}
1719
1720static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
1721{
1722 struct trace_seq *s = &iter->seq;
1723 struct trace_entry *entry = iter->ent;
1724 struct print_entry *field;
1725 int ret;
1726
1727 trace_assign_type(field, entry);
1728
1729 ret = trace_seq_printf(s, "%s", field->buf);
1730 if (!ret)
1731 return TRACE_TYPE_PARTIAL_LINE;
1732
1733 return TRACE_TYPE_HANDLED;
1734}
1735
1736static enum print_line_t print_bin_fmt(struct trace_iterator *iter) 1702static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
1737{ 1703{
1738 struct trace_seq *s = &iter->seq; 1704 struct trace_seq *s = &iter->seq;
@@ -1794,12 +1760,12 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
1794 if (iter->ent->type == TRACE_BPRINT && 1760 if (iter->ent->type == TRACE_BPRINT &&
1795 trace_flags & TRACE_ITER_PRINTK && 1761 trace_flags & TRACE_ITER_PRINTK &&
1796 trace_flags & TRACE_ITER_PRINTK_MSGONLY) 1762 trace_flags & TRACE_ITER_PRINTK_MSGONLY)
1797 return print_bprintk_msg_only(iter); 1763 return trace_print_bprintk_msg_only(iter);
1798 1764
1799 if (iter->ent->type == TRACE_PRINT && 1765 if (iter->ent->type == TRACE_PRINT &&
1800 trace_flags & TRACE_ITER_PRINTK && 1766 trace_flags & TRACE_ITER_PRINTK &&
1801 trace_flags & TRACE_ITER_PRINTK_MSGONLY) 1767 trace_flags & TRACE_ITER_PRINTK_MSGONLY)
1802 return print_printk_msg_only(iter); 1768 return trace_print_printk_msg_only(iter);
1803 1769
1804 if (trace_flags & TRACE_ITER_BIN) 1770 if (trace_flags & TRACE_ITER_BIN)
1805 return print_bin_fmt(iter); 1771 return print_bin_fmt(iter);
@@ -1948,9 +1914,14 @@ int tracing_open_generic(struct inode *inode, struct file *filp)
1948static int tracing_release(struct inode *inode, struct file *file) 1914static int tracing_release(struct inode *inode, struct file *file)
1949{ 1915{
1950 struct seq_file *m = (struct seq_file *)file->private_data; 1916 struct seq_file *m = (struct seq_file *)file->private_data;
1951 struct trace_iterator *iter = m->private; 1917 struct trace_iterator *iter;
1952 int cpu; 1918 int cpu;
1953 1919
1920 if (!(file->f_mode & FMODE_READ))
1921 return 0;
1922
1923 iter = m->private;
1924
1954 mutex_lock(&trace_types_lock); 1925 mutex_lock(&trace_types_lock);
1955 for_each_tracing_cpu(cpu) { 1926 for_each_tracing_cpu(cpu) {
1956 if (iter->buffer_iter[cpu]) 1927 if (iter->buffer_iter[cpu])
@@ -1976,12 +1947,24 @@ static int tracing_open(struct inode *inode, struct file *file)
1976 struct trace_iterator *iter; 1947 struct trace_iterator *iter;
1977 int ret = 0; 1948 int ret = 0;
1978 1949
1979 iter = __tracing_open(inode, file); 1950 /* If this file was open for write, then erase contents */
1980 if (IS_ERR(iter)) 1951 if ((file->f_mode & FMODE_WRITE) &&
1981 ret = PTR_ERR(iter); 1952 !(file->f_flags & O_APPEND)) {
1982 else if (trace_flags & TRACE_ITER_LATENCY_FMT) 1953 long cpu = (long) inode->i_private;
1983 iter->iter_flags |= TRACE_FILE_LAT_FMT;
1984 1954
1955 if (cpu == TRACE_PIPE_ALL_CPU)
1956 tracing_reset_online_cpus(&global_trace);
1957 else
1958 tracing_reset(&global_trace, cpu);
1959 }
1960
1961 if (file->f_mode & FMODE_READ) {
1962 iter = __tracing_open(inode, file);
1963 if (IS_ERR(iter))
1964 ret = PTR_ERR(iter);
1965 else if (trace_flags & TRACE_ITER_LATENCY_FMT)
1966 iter->iter_flags |= TRACE_FILE_LAT_FMT;
1967 }
1985 return ret; 1968 return ret;
1986} 1969}
1987 1970
@@ -2056,9 +2039,17 @@ static int show_traces_open(struct inode *inode, struct file *file)
2056 return ret; 2039 return ret;
2057} 2040}
2058 2041
2042static ssize_t
2043tracing_write_stub(struct file *filp, const char __user *ubuf,
2044 size_t count, loff_t *ppos)
2045{
2046 return count;
2047}
2048
2059static const struct file_operations tracing_fops = { 2049static const struct file_operations tracing_fops = {
2060 .open = tracing_open, 2050 .open = tracing_open,
2061 .read = seq_read, 2051 .read = seq_read,
2052 .write = tracing_write_stub,
2062 .llseek = seq_lseek, 2053 .llseek = seq_lseek,
2063 .release = tracing_release, 2054 .release = tracing_release,
2064}; 2055};
@@ -3154,7 +3145,7 @@ static int mark_printk(const char *fmt, ...)
3154 int ret; 3145 int ret;
3155 va_list args; 3146 va_list args;
3156 va_start(args, fmt); 3147 va_start(args, fmt);
3157 ret = trace_vprintk(0, -1, fmt, args); 3148 ret = trace_vprintk(0, fmt, args);
3158 va_end(args); 3149 va_end(args);
3159 return ret; 3150 return ret;
3160} 3151}
@@ -3583,7 +3574,7 @@ static void tracing_init_debugfs_percpu(long cpu)
3583 pr_warning("Could not create debugfs 'trace_pipe' entry\n"); 3574 pr_warning("Could not create debugfs 'trace_pipe' entry\n");
3584 3575
3585 /* per cpu trace */ 3576 /* per cpu trace */
3586 entry = debugfs_create_file("trace", 0444, d_cpu, 3577 entry = debugfs_create_file("trace", 0644, d_cpu,
3587 (void *) cpu, &tracing_fops); 3578 (void *) cpu, &tracing_fops);
3588 if (!entry) 3579 if (!entry)
3589 pr_warning("Could not create debugfs 'trace' entry\n"); 3580 pr_warning("Could not create debugfs 'trace' entry\n");
@@ -3897,7 +3888,7 @@ static __init int tracer_init_debugfs(void)
3897 if (!entry) 3888 if (!entry)
3898 pr_warning("Could not create debugfs 'tracing_cpumask' entry\n"); 3889 pr_warning("Could not create debugfs 'tracing_cpumask' entry\n");
3899 3890
3900 entry = debugfs_create_file("trace", 0444, d_tracer, 3891 entry = debugfs_create_file("trace", 0644, d_tracer,
3901 (void *) TRACE_PIPE_ALL_CPU, &tracing_fops); 3892 (void *) TRACE_PIPE_ALL_CPU, &tracing_fops);
3902 if (!entry) 3893 if (!entry)
3903 pr_warning("Could not create debugfs 'trace' entry\n"); 3894 pr_warning("Could not create debugfs 'trace' entry\n");