Skip to content

Commit 8dd33bc

Browse files
byannvrostedt
authored andcommitted
tracing: Erase irqsoff trace with empty write
One convenient way to erase trace is "echo > trace". However, this is currently broken if the current tracer is irqsoff tracer. This is because irqsoff tracer use max_buffer as the default trace buffer. Set the max_buffer as the one to be cleared when it's the trace buffer currently in use. Link: http://lkml.kernel.org/r/[email protected] Cc: <[email protected]> Cc: [email protected] Fixes: 4acd4d0 ("tracing: give easy way to clear trace buffer") Signed-off-by: Bo Yan <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 170b3b1 commit 8dd33bc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,11 +4020,17 @@ static int tracing_open(struct inode *inode, struct file *file)
40204020
/* If this file was open for write, then erase contents */
40214021
if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
40224022
int cpu = tracing_get_cpu(inode);
4023+
struct trace_buffer *trace_buf = &tr->trace_buffer;
4024+
4025+
#ifdef CONFIG_TRACER_MAX_TRACE
4026+
if (tr->current_trace->print_max)
4027+
trace_buf = &tr->max_buffer;
4028+
#endif
40234029

40244030
if (cpu == RING_BUFFER_ALL_CPUS)
4025-
tracing_reset_online_cpus(&tr->trace_buffer);
4031+
tracing_reset_online_cpus(trace_buf);
40264032
else
4027-
tracing_reset(&tr->trace_buffer, cpu);
4033+
tracing_reset(trace_buf, cpu);
40284034
}
40294035

40304036
if (file->f_mode & FMODE_READ) {

0 commit comments

Comments
 (0)