public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
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 <vdonnefort@google.com>
Subject: [PATCH v13 12/32] ring-buffer: Export buffer_data_page and macros
Date: Fri,  6 Mar 2026 14:35:16 +0000	[thread overview]
Message-ID: <20260306143536.339777-13-vdonnefort@google.com> (raw)
In-Reply-To: <20260306143536.339777-1-vdonnefort@google.com>

In preparation for allowing the writing of ring-buffer compliant pages
outside of ring_buffer.c, move buffer_data_page and timestamps encoding
macros into the publicly available ring_buffer_types.h.

Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>

diff --git a/include/linux/ring_buffer_types.h b/include/linux/ring_buffer_types.h
new file mode 100644
index 000000000000..54577021a49d
--- /dev/null
+++ b/include/linux/ring_buffer_types.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_RING_BUFFER_TYPES_H
+#define _LINUX_RING_BUFFER_TYPES_H
+
+#include <asm/local.h>
+
+#define TS_SHIFT        27
+#define TS_MASK         ((1ULL << TS_SHIFT) - 1)
+#define TS_DELTA_TEST   (~TS_MASK)
+
+/*
+ * We need to fit the time_stamp delta into 27 bits.
+ */
+static inline bool test_time_stamp(u64 delta)
+{
+	return !!(delta & TS_DELTA_TEST);
+}
+
+#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
+
+#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
+#define RB_ALIGNMENT		4U
+#define RB_MAX_SMALL_DATA	(RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
+#define RB_EVNT_MIN_SIZE	8U	/* two 32bit words */
+
+#ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS
+# define RB_FORCE_8BYTE_ALIGNMENT	0
+# define RB_ARCH_ALIGNMENT		RB_ALIGNMENT
+#else
+# define RB_FORCE_8BYTE_ALIGNMENT	1
+# define RB_ARCH_ALIGNMENT		8U
+#endif
+
+#define RB_ALIGN_DATA		__aligned(RB_ARCH_ALIGNMENT)
+
+struct buffer_data_page {
+	u64		 time_stamp;	/* page time stamp */
+	local_t		 commit;	/* write committed index */
+	unsigned char	 data[] RB_ALIGN_DATA;	/* data of buffer page */
+};
+#endif
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 60492e66a679..d92b615e9246 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
  */
+#include <linux/ring_buffer_types.h>
 #include <linux/sched/isolation.h>
 #include <linux/trace_recursion.h>
 #include <linux/trace_events.h>
@@ -157,23 +158,6 @@ int ring_buffer_print_entry_header(struct trace_seq *s)
 /* Used for individual buffers (after the counter) */
 #define RB_BUFFER_OFF		(1 << 20)
 
-#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
-
-#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
-#define RB_ALIGNMENT		4U
-#define RB_MAX_SMALL_DATA	(RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
-#define RB_EVNT_MIN_SIZE	8U	/* two 32bit words */
-
-#ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS
-# define RB_FORCE_8BYTE_ALIGNMENT	0
-# define RB_ARCH_ALIGNMENT		RB_ALIGNMENT
-#else
-# define RB_FORCE_8BYTE_ALIGNMENT	1
-# define RB_ARCH_ALIGNMENT		8U
-#endif
-
-#define RB_ALIGN_DATA		__aligned(RB_ARCH_ALIGNMENT)
-
 /* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
 #define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX
 
@@ -316,10 +300,6 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data);
 #define for_each_online_buffer_cpu(buffer, cpu)		\
 	for_each_cpu_and(cpu, buffer->cpumask, cpu_online_mask)
 
-#define TS_SHIFT	27
-#define TS_MASK		((1ULL << TS_SHIFT) - 1)
-#define TS_DELTA_TEST	(~TS_MASK)
-
 static u64 rb_event_time_stamp(struct ring_buffer_event *event)
 {
 	u64 ts;
@@ -338,12 +318,6 @@ static u64 rb_event_time_stamp(struct ring_buffer_event *event)
 
 #define RB_MISSED_MASK		(3 << 30)
 
-struct buffer_data_page {
-	u64		 time_stamp;	/* page time stamp */
-	local_t		 commit;	/* write committed index */
-	unsigned char	 data[] RB_ALIGN_DATA;	/* data of buffer page */
-};
-
 struct buffer_data_read_page {
 	unsigned		order;	/* order of the page */
 	struct buffer_data_page	*data;	/* actual data, stored in this page */
@@ -437,14 +411,6 @@ static struct buffer_data_page *alloc_cpu_data(int cpu, int order)
 	return dpage;
 }
 
-/*
- * We need to fit the time_stamp delta into 27 bits.
- */
-static inline bool test_time_stamp(u64 delta)
-{
-	return !!(delta & TS_DELTA_TEST);
-}
-
 struct rb_irq_work {
 	struct irq_work			work;
 	wait_queue_head_t		waiters;
-- 
2.53.0.473.g4a7958ca14-goog


  parent reply	other threads:[~2026-03-06 14:36 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 14:35 [PATCH v13 00/32] Tracefs support for pKVM Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 01/32] ring-buffer: Add page statistics to the meta-page Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 02/32] ring-buffer: Store bpage pointers into subbuf_ids Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 03/32] ring-buffer: Introduce ring-buffer remotes Vincent Donnefort
2026-03-06 16:37   ` Markus Elfring
2026-03-11 15:23     ` Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 04/32] ring-buffer: Add non-consuming read for " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 05/32] tracing: Introduce trace remotes Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 06/32] tracing: Add reset to " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 07/32] tracing: Add non-consuming read " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 08/32] tracing: Add init callback " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 09/32] tracing: Add events " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 10/32] tracing: Add events/ root files " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 11/32] tracing: Add helpers to create trace remote events Vincent Donnefort
2026-03-06 14:35 ` Vincent Donnefort [this message]
2026-03-06 14:35 ` [PATCH v13 13/32] tracing: Introduce simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 14/32] tracing: Add a trace remote module for testing Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 15/32] tracing: selftests: Add trace remote tests Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 16/32] Documentation: tracing: Add tracing remotes Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 17/32] tracing: load/unload page callbacks for simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 18/32] tracing: Check for undefined symbols in simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 19/32] KVM: arm64: Add PKVM_DISABLE_STAGE2_ON_PANIC Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 20/32] KVM: arm64: Add clock support to nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 21/32] KVM: arm64: Initialise hyp_nr_cpus for nVHE hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 22/32] KVM: arm64: Support unaligned fixmap in the pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 23/32] KVM: arm64: Add tracing capability for the nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 24/32] KVM: arm64: Add trace remote " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 25/32] KVM: arm64: Sync boot clock with " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 26/32] KVM: arm64: Add trace reset to " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 27/32] KVM: arm64: Add event support to the nVHE/pKVM hyp and trace remote Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 28/32] KVM: arm64: Add hyp_enter/hyp_exit events to nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 29/32] KVM: arm64: Add selftest event support " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 30/32] tracing: selftests: Add hypervisor trace remote tests Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 31/32] fixup! tracing: Add a trace remote module for testing Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 32/32] " Vincent Donnefort
2026-03-09  1:45 ` [PATCH v13 00/32] Tracefs support for pKVM Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260306143536.339777-13-vdonnefort@google.com \
    --to=vdonnefort@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=joey.gouly@arm.com \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=maz@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=rostedt@goodmis.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox