Commit 96e43537 authored by Vincent Donnefort's avatar Vincent Donnefort Committed by Steven Rostedt (Google)
Browse files

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: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarVincent Donnefort <vdonnefort@google.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent fbd1743e
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
/* 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 −0
Original line number Diff line number Diff line
@@ -1281,4 +1281,7 @@ config HIST_TRIGGERS_DEBUG

source "kernel/trace/rv/Kconfig"

config TRACE_REMOTE
	bool

endif # FTRACE
+1 −0
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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);


/**
Loading