From nobody Thu Apr 2 17:22:44 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F66E3ED127 for ; Mon, 9 Mar 2026 16:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773073580; cv=none; b=Qmr8gxeizY3WZWKGc/Q1UQ+8XRDPTtHvj4onVu/U1s0oZtIGOvEW6zXvrMN2KmXCxfZINluJ8/V5Vvsef8qqdtxZfReioi2m7R+FXSrVvCS5eSUeuiWXAC/4UfZOfQ0DcTEjZVQbfxJL+c74Vf1Gnvpr0dRqP+MU/FDEGrkcrC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773073580; c=relaxed/simple; bh=7bMiRK0ShivdAJEqAqq8p+bSixyyMffBJzLzrorCG00=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Sh1b6nsVHgnS3cNU3H0SkYw7F2ok9uuTmOJJTNj/V58xW0Xh5lCajiT8vyj3tSD+u2ybLT0Oe8SoQHvYDP0dHyL51RPC+tI1+r53jh4cSA7uUISkW2eHg3xXYx0lNdierG+vK1CC9xAGnm+qeLPwRwnKAPLcna5joTNoDcE0aoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rdenp2Mi; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rdenp2Mi" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-485375aa56eso11812265e9.1 for ; Mon, 09 Mar 2026 09:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773073576; x=1773678376; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=B6OW0CQFlfUo8gIs8zWJuy/R7hSbmdzTUEKNvWrAy54=; b=rdenp2Mi2F9tuDr3+sujTkP1myqg1QviDs4jR/S67Py1Ip5Fm+FZJL/KinuprOr7Gq w1nglGl4zXdSP8rdTPipo4NavbMyuSagIZjWHw1eTlLNuN6go/ahSS9DVfvznlbZGFEu bK9FBwyYjLbKIRdOSBiRFdCKT3v6EDPIBckigV9DobdFPfembcgzpZtf0ccDD+ha+zfG eEcZnYwG0f/Or8JZiZ5aMyrlqPU+YoWyIomp4oel3P9ubO/NtICwJwVx8M16gz5SUA5q L2Pz0ADrihUMksPugl3hKZgADaWJUwB64GuBizkWPGGMM85BNQz5x7FreXiU00h8o+kA tCHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773073576; x=1773678376; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B6OW0CQFlfUo8gIs8zWJuy/R7hSbmdzTUEKNvWrAy54=; b=wiaY6dSU7s+37KGnZBgPEPJzYSohNHCiFMAy5ki9BQL5RMoRB6nVSiKZBQbpIy2daS crOgBzjbQWo5x8UyE8R5wPJ2X59n0DzAXncHElSuZdGB9X22LIowMMh5Sj+zHZ2QPbdF eMWJyU45gN4DyIEtDT99eNhV9IKX3QWXUqCquTUlkraRR2zxuMVCgqZUdU9xxrKaGrNT jaryC+gURkBPP1OZdjZGnu7q6uwMeoslvHQk8FUs4l9fvP63QYn8ZYPlKrdejW9mEHrk 0Ao3gLrwL7deMnvuPAKKBTLVmDqac34VPWTeHkmHa/PFNqE9a8VrnRo7IzRaW7l3MUNE nP3Q== X-Forwarded-Encrypted: i=1; AJvYcCVSIgzPzYJbxPo9xstrIo+JHfx92+yMN9HSasuYQWlmQAVNJzbBnTQ0DiS2SwljsAC4FEeNxwD3hqRnC+c=@vger.kernel.org X-Gm-Message-State: AOJu0Yy24vo4R5RkyFb3wGzpPjJP4adfO7GAU+QldQ6z+QOb7jZqKJzD XPaUragHtFY54D1ke6kEQIPWIxrsI+ZVQSHUAaTFkqEsumS44e6TjmkB4NTIAbWYHyYFcMznAMA JVULARRthPVGwS96WCDbCtQ== X-Received: from wmmr21.prod.google.com ([2002:a05:600c:4255:b0:485:35d3:c8b9]) (user=vdonnefort job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d0b:b0:485:4136:99a8 with SMTP id 5b1f17b1804b1-48541369c0cmr13223965e9.22.1773073576611; Mon, 09 Mar 2026 09:26:16 -0700 (PDT) Date: Mon, 9 Mar 2026 16:25:02 +0000 In-Reply-To: <20260309162516.2623589-1-vdonnefort@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260309162516.2623589-1-vdonnefort@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309162516.2623589-17-vdonnefort@google.com> Subject: [PATCH v14 16/30] Documentation: tracing: Add tracing remotes From: Vincent Donnefort To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jstultz@google.com, qperret@google.com, will@kernel.org, aneesh.kumar@kernel.org, kernel-team@android.com, linux-kernel@vger.kernel.org, Vincent Donnefort Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add documentation about the newly introduced tracing remotes framework. Reviewed-by: Steven Rostedt (Google) Signed-off-by: Vincent Donnefort 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 =20 +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 -------------------- =20 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 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Tracing Remotes +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +:Author: Vincent Donnefort + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D +Firmware and hypervisors are black boxes to the kernel. Having a way to se= e what +they are doing can be useful to debug both. This is where remote tracing b= uffers +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 s= imilar +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" s= ide. +With a trace remote ring buffer, the firmware and hypervisor can record ev= ents +for which the host kernel can see and expose to user space. + +Register a remote +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +A remote must provide a set of callbacks `struct trace_remote_callbacks` w= hom +description can be found below. Those callbacks allows Tracefs to enable a= nd +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 f= iles +**trace_pipe** and **trace**. + +Declare a remote event +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +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 descripti= on 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=3D%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 giv= en to +`trace_remote_register`. + +Registered events appear in the remote directory under **events/**. + +Simple ring-buffer +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +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 --=20 2.53.0.473.g4a7958ca14-goog