Skip to content

Commit 06e0a54

Browse files
committed
tracing: Do not disable tracing when reading the trace file
When opening the "trace" file, it is no longer necessary to disable tracing. Note, a new option is created called "pause-on-trace", when set, will cause the trace file to emulate its original behavior. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 1039221 commit 06e0a54

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Documentation/trace/ftrace.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,12 @@ Here are the available options:
11251125
the trace displays additional information about the
11261126
latency, as described in "Latency trace format".
11271127

1128+
pause-on-trace
1129+
When set, opening the trace file for read, will pause
1130+
writing to the ring buffer (as if tracing_on was set to zero).
1131+
This simulates the original behavior of the trace file.
1132+
When the file is closed, tracing will be enabled again.
1133+
11281134
record-cmd
11291135
When any event or tracer is enabled, a hook is enabled
11301136
in the sched_switch trace point to fill comm cache

kernel/trace/trace.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4273,8 +4273,11 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
42734273
if (trace_clocks[tr->clock_id].in_ns)
42744274
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
42754275

4276-
/* stop the trace while dumping if we are not opening "snapshot" */
4277-
if (!iter->snapshot)
4276+
/*
4277+
* If pause-on-trace is enabled, then stop the trace while
4278+
* dumping, unless this is the "snapshot" file
4279+
*/
4280+
if (!iter->snapshot && (tr->trace_flags & TRACE_ITER_PAUSE_ON_TRACE))
42784281
tracing_stop_tr(tr);
42794282

42804283
if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
@@ -4371,7 +4374,7 @@ static int tracing_release(struct inode *inode, struct file *file)
43714374
if (iter->trace && iter->trace->close)
43724375
iter->trace->close(iter);
43734376

4374-
if (!iter->snapshot)
4377+
if (!iter->snapshot && tr->stop_count)
43754378
/* reenable tracing if it was previously enabled */
43764379
tracing_start_tr(tr);
43774380

kernel/trace/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
13021302
C(IRQ_INFO, "irq-info"), \
13031303
C(MARKERS, "markers"), \
13041304
C(EVENT_FORK, "event-fork"), \
1305+
C(PAUSE_ON_TRACE, "pause-on-trace"), \
13051306
FUNCTION_FLAGS \
13061307
FGRAPH_FLAGS \
13071308
STACK_FLAGS \

0 commit comments

Comments
 (0)