From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E2D43064A0 for ; Tue, 10 Mar 2026 14:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773153355; cv=none; b=hnNWrs+z5s9NxD5QbupTi2ahh4pw9rSTZgO1L82m4E/HBQBlJfrx4Pw0HQPqYadwI05fkvT24L5xYGwXeHMUfQzEbG2ez740nZDcve4V5W2aznXGOOfFRs2kk+1zEd1bnNqW68FD6yMB2GtIMhN+eK3zWh80IsYqaoQ08wkqS/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773153355; c=relaxed/simple; bh=PID+VqUsBjWlkbaIcb4BYdf2OTIOq3zumzFsYHTcZIo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ttY92aKICCQ4bE4G+e1OAN+WlehVA+rJctKwnEU4RzHcKICjg90BvWvZW+IUdGqLVNJHfOXVPGnbNcoGB4dDihgx1ev79UMLTwhXNbM00g/it6vDintADPddMbGIh8/oveY2P6qrCmiEIc9ueHSF5ZQD7ewkN2tHzioAiBzzNsg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oOSnKCc6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oOSnKCc6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F201C2BCAF; Tue, 10 Mar 2026 14:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773153355; bh=PID+VqUsBjWlkbaIcb4BYdf2OTIOq3zumzFsYHTcZIo=; h=Date:From:To:Cc:Subject:References:From; b=oOSnKCc6MeE58icmX8RuG0yICxlE2WrsJ8wkTCP7+oNyVg1XWxU7Lbt7wiUmLfbie erOp6h43aa6vnjusqJNaZgey4PAYz7hlSgwmuhrjEWEIjeIox9QSkhJfT4Kht1bV60 mTU9xtKf8mk02aiJ2ONkljeqoY9Jsv5QjPSar9jnMrSCn/RIKoArvSQZmuZigQS0Oh dX7dIp0XASIuaE3c2Xd1vuk3giY7Nbi5APquLttbXg+26irEuRY8xRPkIb8SmV0dJm fhlSKrWaKz+JZ5P6iPlFoXYjSclBBz3UyqLRTrCPJpTfJorz24EMhdDpigrtm0Zcev 4jxzaTBkhHj+w== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1vzyBp-00000002ZhH-0Ypi; Tue, 10 Mar 2026 10:36:05 -0400 Message-ID: <20260310143605.009065973@kernel.org> User-Agent: quilt/0.69 Date: Tue, 10 Mar 2026 10:35:31 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-next][PATCH 16/18] Documentation: tracing: Add tracing remotes References: <20260310143515.132579088@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Vincent Donnefort Add documentation about the newly introduced tracing remotes framework. Link: https://patch.msgid.link/20260309162516.2623589-17-vdonnefort@google.com Reviewed-by: Steven Rostedt (Google) Signed-off-by: Vincent Donnefort Signed-off-by: Steven Rostedt (Google) --- Documentation/trace/index.rst | 11 ++++++ Documentation/trace/remotes.rst | 66 +++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Documentation/trace/remotes.rst diff --git a/Documentation/trace/index.rst b/Documentation/trace/index.rst index 338bc4d7cfab..036db96864d2 100644 --- a/Documentation/trace/index.rst +++ b/Documentation/trace/index.rst @@ -91,6 +91,17 @@ interactions. user_events uprobetracer +Remote Tracing +-------------- + +This section covers the framework to read compatible ring-buffers, written by +entities outside of the kernel (most likely firmware or hypervisor) + +.. toctree:: + :maxdepth: 1 + + remotes + Additional Resources -------------------- diff --git a/Documentation/trace/remotes.rst b/Documentation/trace/remotes.rst new file mode 100644 index 000000000000..1f9d764f69aa --- /dev/null +++ b/Documentation/trace/remotes.rst @@ -0,0 +1,66 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=============== +Tracing Remotes +=============== + +:Author: Vincent Donnefort + +Overview +======== +Firmware and hypervisors are black boxes to the kernel. Having a way to see what +they are doing can be useful to debug both. This is where remote tracing buffers +come in. A remote tracing buffer is a ring buffer executed by the firmware or +hypervisor into memory that is memory mapped to the host kernel. This is similar +to how user space memory maps the kernel ring buffer but in this case the kernel +is acting like user space and the firmware or hypervisor is the "kernel" side. +With a trace remote ring buffer, the firmware and hypervisor can record events +for which the host kernel can see and expose to user space. + +Register a remote +================= +A remote must provide a set of callbacks `struct trace_remote_callbacks` whom +description can be found below. Those callbacks allows Tracefs to enable and +disable tracing and events, to load and unload a tracing buffer (a set of +ring-buffers) and to swap a reader page with the head page, which enables +consuming reading. + +.. kernel-doc:: include/linux/trace_remote.h + +Once registered, an instance will appear for this remote in the Tracefs +directory **remotes/**. Buffers can then be read using the usual Tracefs files +**trace_pipe** and **trace**. + +Declare a remote event +====================== +Macros are provided to ease the declaration of remote events, in a similar +fashion to in-kernel events. A declaration must provide an ID, a description of +the event arguments and how to print the event: + +.. code-block:: c + + REMOTE_EVENT(foo, EVENT_FOO_ID, + RE_STRUCT( + re_field(u64, bar) + ), + RE_PRINTK("bar=%lld", __entry->bar) + ); + +Then those events must be declared in a C file with the following: + +.. code-block:: c + + #define REMOTE_EVENT_INCLUDE_FILE foo_events.h + #include + +This will provide a `struct remote_event remote_event_foo` that can be given to +`trace_remote_register`. + +Registered events appear in the remote directory under **events/**. + +Simple ring-buffer +================== +A simple implementation for a ring-buffer writer can be found in +kernel/trace/simple_ring_buffer.c. + +.. kernel-doc:: include/linux/simple_ring_buffer.h -- 2.51.0