Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Add tracer_tracing_disable/enable() functions

Allow a tracer to disable writing to its buffer for a temporary amount of
time and re-enable it.

The tracer_tracing_disable() will disable writing to the trace array
buffer, and requires a tracer_tracing_enable() to re-enable it.

The difference between tracer_tracing_disable() and tracer_tracing_off()
is that the disable version can nest, and requires as many enable() calls
as disable() calls to re-enable the buffer. Where as the off() function
can be called multiple times and only requires a singe tracer_tracing_on()
to re-enable the buffer.

Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Daniel Thompson <danielt@kernel.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/20250505212235.210330010@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+35
+33
kernel/trace/trace.c
··· 1583 1583 } 1584 1584 1585 1585 /** 1586 + * tracer_tracing_disable() - temporary disable the buffer from write 1587 + * @tr: The trace array to disable its buffer for 1588 + * 1589 + * Expects trace_tracing_enable() to re-enable tracing. 1590 + * The difference between this and tracer_tracing_off() is that this 1591 + * is a counter and can nest, whereas, tracer_tracing_off() can 1592 + * be called multiple times and a single trace_tracing_on() will 1593 + * enable it. 1594 + */ 1595 + void tracer_tracing_disable(struct trace_array *tr) 1596 + { 1597 + if (WARN_ON_ONCE(!tr->array_buffer.buffer)) 1598 + return; 1599 + 1600 + ring_buffer_record_disable(tr->array_buffer.buffer); 1601 + } 1602 + 1603 + /** 1604 + * tracer_tracing_enable() - counter part of tracer_tracing_disable() 1605 + * @tr: The trace array that had tracer_tracincg_disable() called on it 1606 + * 1607 + * This is called after tracer_tracing_disable() has been called on @tr, 1608 + * when it's safe to re-enable tracing. 1609 + */ 1610 + void tracer_tracing_enable(struct trace_array *tr) 1611 + { 1612 + if (WARN_ON_ONCE(!tr->array_buffer.buffer)) 1613 + return; 1614 + 1615 + ring_buffer_record_enable(tr->array_buffer.buffer); 1616 + } 1617 + 1618 + /** 1586 1619 * tracing_off - turn off tracing buffers 1587 1620 * 1588 1621 * This function stops the tracing buffers from recording data.
+2
kernel/trace/trace.h
··· 665 665 bool tracer_tracing_is_on(struct trace_array *tr); 666 666 void tracer_tracing_on(struct trace_array *tr); 667 667 void tracer_tracing_off(struct trace_array *tr); 668 + void tracer_tracing_disable(struct trace_array *tr); 669 + void tracer_tracing_enable(struct trace_array *tr); 668 670 struct dentry *trace_create_file(const char *name, 669 671 umode_t mode, 670 672 struct dentry *parent,