diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a2d13e8c8fd8..8d981ababc45 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1941,9 +1941,14 @@ int tracing_open_generic(struct inode *inode, struct file *filp) | |||
1941 | static int tracing_release(struct inode *inode, struct file *file) | 1941 | static int tracing_release(struct inode *inode, struct file *file) |
1942 | { | 1942 | { |
1943 | struct seq_file *m = (struct seq_file *)file->private_data; | 1943 | struct seq_file *m = (struct seq_file *)file->private_data; |
1944 | struct trace_iterator *iter = m->private; | 1944 | struct trace_iterator *iter; |
1945 | int cpu; | 1945 | int cpu; |
1946 | 1946 | ||
1947 | if (!(file->f_mode & FMODE_READ)) | ||
1948 | return 0; | ||
1949 | |||
1950 | iter = m->private; | ||
1951 | |||
1947 | mutex_lock(&trace_types_lock); | 1952 | mutex_lock(&trace_types_lock); |
1948 | for_each_tracing_cpu(cpu) { | 1953 | for_each_tracing_cpu(cpu) { |
1949 | if (iter->buffer_iter[cpu]) | 1954 | if (iter->buffer_iter[cpu]) |
@@ -1969,12 +1974,24 @@ static int tracing_open(struct inode *inode, struct file *file) | |||
1969 | struct trace_iterator *iter; | 1974 | struct trace_iterator *iter; |
1970 | int ret = 0; | 1975 | int ret = 0; |
1971 | 1976 | ||
1972 | iter = __tracing_open(inode, file); | 1977 | /* If this file was open for write, then erase contents */ |
1973 | if (IS_ERR(iter)) | 1978 | if ((file->f_mode & FMODE_WRITE) && |
1974 | ret = PTR_ERR(iter); | 1979 | !(file->f_flags & O_APPEND)) { |
1975 | else if (trace_flags & TRACE_ITER_LATENCY_FMT) | 1980 | long cpu = (long) inode->i_private; |
1976 | iter->iter_flags |= TRACE_FILE_LAT_FMT; | 1981 | |
1982 | if (cpu == TRACE_PIPE_ALL_CPU) | ||
1983 | tracing_reset_online_cpus(&global_trace); | ||
1984 | else | ||
1985 | tracing_reset(&global_trace, cpu); | ||
1986 | } | ||
1977 | 1987 | ||
1988 | if (file->f_mode & FMODE_READ) { | ||
1989 | iter = __tracing_open(inode, file); | ||
1990 | if (IS_ERR(iter)) | ||
1991 | ret = PTR_ERR(iter); | ||
1992 | else if (trace_flags & TRACE_ITER_LATENCY_FMT) | ||
1993 | iter->iter_flags |= TRACE_FILE_LAT_FMT; | ||
1994 | } | ||
1978 | return ret; | 1995 | return ret; |
1979 | } | 1996 | } |
1980 | 1997 | ||
@@ -2049,9 +2066,17 @@ static int show_traces_open(struct inode *inode, struct file *file) | |||
2049 | return ret; | 2066 | return ret; |
2050 | } | 2067 | } |
2051 | 2068 | ||
2069 | static ssize_t | ||
2070 | tracing_write_stub(struct file *filp, const char __user *ubuf, | ||
2071 | size_t count, loff_t *ppos) | ||
2072 | { | ||
2073 | return count; | ||
2074 | } | ||
2075 | |||
2052 | static const struct file_operations tracing_fops = { | 2076 | static const struct file_operations tracing_fops = { |
2053 | .open = tracing_open, | 2077 | .open = tracing_open, |
2054 | .read = seq_read, | 2078 | .read = seq_read, |
2079 | .write = tracing_write_stub, | ||
2055 | .llseek = seq_lseek, | 2080 | .llseek = seq_lseek, |
2056 | .release = tracing_release, | 2081 | .release = tracing_release, |
2057 | }; | 2082 | }; |
@@ -3576,7 +3601,7 @@ static void tracing_init_debugfs_percpu(long cpu) | |||
3576 | pr_warning("Could not create debugfs 'trace_pipe' entry\n"); | 3601 | pr_warning("Could not create debugfs 'trace_pipe' entry\n"); |
3577 | 3602 | ||
3578 | /* per cpu trace */ | 3603 | /* per cpu trace */ |
3579 | entry = debugfs_create_file("trace", 0444, d_cpu, | 3604 | entry = debugfs_create_file("trace", 0644, d_cpu, |
3580 | (void *) cpu, &tracing_fops); | 3605 | (void *) cpu, &tracing_fops); |
3581 | if (!entry) | 3606 | if (!entry) |
3582 | pr_warning("Could not create debugfs 'trace' entry\n"); | 3607 | pr_warning("Could not create debugfs 'trace' entry\n"); |
@@ -3890,7 +3915,7 @@ static __init int tracer_init_debugfs(void) | |||
3890 | if (!entry) | 3915 | if (!entry) |
3891 | pr_warning("Could not create debugfs 'tracing_cpumask' entry\n"); | 3916 | pr_warning("Could not create debugfs 'tracing_cpumask' entry\n"); |
3892 | 3917 | ||
3893 | entry = debugfs_create_file("trace", 0444, d_tracer, | 3918 | entry = debugfs_create_file("trace", 0644, d_tracer, |
3894 | (void *) TRACE_PIPE_ALL_CPU, &tracing_fops); | 3919 | (void *) TRACE_PIPE_ALL_CPU, &tracing_fops); |
3895 | if (!entry) | 3920 | if (!entry) |
3896 | pr_warning("Could not create debugfs 'trace' entry\n"); | 3921 | pr_warning("Could not create debugfs 'trace' entry\n"); |