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.

ring-buffer: Add ring_buffer_record_is_on_cpu()

Add the function ring_buffer_record_is_on_cpu() that returns true if the
ring buffer for a give CPU is writable and false otherwise.

Also add tracer_tracing_is_on_cpu() to return if the ring buffer for a
given CPU is writeable for a given trace_array.

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>
Link: https://lore.kernel.org/20250505212236.059853898@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+34
+1
include/linux/ring_buffer.h
··· 192 192 void ring_buffer_record_on(struct trace_buffer *buffer); 193 193 bool ring_buffer_record_is_on(struct trace_buffer *buffer); 194 194 bool ring_buffer_record_is_set_on(struct trace_buffer *buffer); 195 + bool ring_buffer_record_is_on_cpu(struct trace_buffer *buffer, int cpu); 195 196 void ring_buffer_record_disable_cpu(struct trace_buffer *buffer, int cpu); 196 197 void ring_buffer_record_enable_cpu(struct trace_buffer *buffer, int cpu); 197 198
+18
kernel/trace/ring_buffer.c
··· 4883 4883 } 4884 4884 4885 4885 /** 4886 + * ring_buffer_record_is_on_cpu - return true if the ring buffer can write 4887 + * @buffer: The ring buffer to see if write is enabled 4888 + * @cpu: The CPU to test if the ring buffer can write too 4889 + * 4890 + * Returns true if the ring buffer is in a state that it accepts writes 4891 + * for a particular CPU. 4892 + */ 4893 + bool ring_buffer_record_is_on_cpu(struct trace_buffer *buffer, int cpu) 4894 + { 4895 + struct ring_buffer_per_cpu *cpu_buffer; 4896 + 4897 + cpu_buffer = buffer->buffers[cpu]; 4898 + 4899 + return ring_buffer_record_is_set_on(buffer) && 4900 + !atomic_read(&cpu_buffer->record_disabled); 4901 + } 4902 + 4903 + /** 4886 4904 * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer 4887 4905 * @buffer: The ring buffer to stop writes to. 4888 4906 * @cpu: The CPU buffer to stop
+15
kernel/trace/trace.h
··· 673 673 void *data, 674 674 const struct file_operations *fops); 675 675 676 + 677 + /** 678 + * tracer_tracing_is_on_cpu - show real state of ring buffer enabled on for a cpu 679 + * @tr : the trace array to know if ring buffer is enabled 680 + * @cpu: The cpu buffer to check if enabled 681 + * 682 + * Shows real state of the per CPU buffer if it is enabled or not. 683 + */ 684 + static inline bool tracer_tracing_is_on_cpu(struct trace_array *tr, int cpu) 685 + { 686 + if (tr->array_buffer.buffer) 687 + return ring_buffer_record_is_on_cpu(tr->array_buffer.buffer, cpu); 688 + return false; 689 + } 690 + 676 691 int tracing_init_dentry(void); 677 692 678 693 struct ring_buffer_event;