tracing: Introduce trace remotes

A trace remote relies on ring-buffer remotes to read and control
compatible tracing buffers, written by entity such as firmware or
hypervisor.

Add a Tracefs directory remotes/ that contains all instances of trace
remotes. Each instance follows the same hierarchy as any other to ease
the support by existing user-space tools.

This currently does not provide any event support, which will come
later.

Link: https://patch.msgid.link/20260309162516.2623589-6-vdonnefort@google.com
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Vincent Donnefort
2026-03-09 12:33:53 -04:00
committed by Steven Rostedt (Google)
parent fbd1743ecb
commit 96e43537af
6 changed files with 666 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_TRACE_REMOTE_H
#define _LINUX_TRACE_REMOTE_H
#include <linux/ring_buffer.h>
/**
* struct trace_remote_callbacks - Callbacks used by Tracefs to control the remote
* @load_trace_buffer: Called before Tracefs accesses the trace buffer for the first
* time. Must return a &trace_buffer_desc
* (most likely filled with trace_remote_alloc_buffer())
* @unload_trace_buffer:
* Called once Tracefs has no use for the trace buffer
* (most likely call trace_remote_free_buffer())
* @enable_tracing: Called on Tracefs tracing_on. It is expected from the
* remote to allow writing.
* @swap_reader_page: Called when Tracefs consumes a new page from a
* ring-buffer. It is expected from the remote to isolate a
* new reader-page from the @cpu ring-buffer.
*/
struct trace_remote_callbacks {
struct trace_buffer_desc *(*load_trace_buffer)(unsigned long size, void *priv);
void (*unload_trace_buffer)(struct trace_buffer_desc *desc, void *priv);
int (*enable_tracing)(bool enable, void *priv);
int (*swap_reader_page)(unsigned int cpu, void *priv);
};
int trace_remote_register(const char *name, struct trace_remote_callbacks *cbs, void *priv);
int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size, size_t buffer_size,
const struct cpumask *cpumask);
void trace_remote_free_buffer(struct trace_buffer_desc *desc);
#endif
+3
View File
@@ -1281,4 +1281,7 @@ config HIST_TRIGGERS_DEBUG
source "kernel/trace/rv/Kconfig"
config TRACE_REMOTE
bool
endif # FTRACE
+1
View File
@@ -128,4 +128,5 @@ obj-$(CONFIG_FPROBE_EVENTS) += trace_fprobe.o
obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
obj-$(CONFIG_RV) += rv/
obj-$(CONFIG_TRACE_REMOTE) += trace_remote.o
libftrace-y := ftrace.o
+1 -1
View File
@@ -8589,7 +8589,7 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
return tr->percpu_dir;
}
static struct dentry *
struct dentry *
trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
void *data, long cpu, const struct file_operations *fops)
{
+6
View File
@@ -689,6 +689,12 @@ struct dentry *trace_create_file(const char *name,
struct dentry *parent,
void *data,
const struct file_operations *fops);
struct dentry *trace_create_cpu_file(const char *name,
umode_t mode,
struct dentry *parent,
void *data,
long cpu,
const struct file_operations *fops);
/**
File diff suppressed because it is too large Load Diff