linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org, x86@kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrii Nakryiko <andrii@kernel.org>,
	Indu Bhagat <indu.bhagat@oracle.com>,
	"Jose E. Marchesi" <jemarch@gnu.org>,
	Beau Belgrave <beaub@linux.microsoft.com>,
	Jens Remus <jremus@linux.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Florian Weimer <fweimer@redhat.com>, Sam James <sam@gentoo.org>,
	Kees Cook <kees@kernel.org>,
	"Carlos O'Donell" <codonell@redhat.com>
Subject: [PATCH v6 2/6] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events
Date: Thu, 28 Aug 2025 14:03:02 -0400	[thread overview]
Message-ID: <20250828180356.716157474@kernel.org> (raw)
In-Reply-To: 20250828180300.591225320@kernel.org

From: Steven Rostedt <rostedt@goodmis.org>

The ftrace events (like function, trace_print, etc) are created somewhat
manually and not via the TRACE_EVENT() or tracepoint magic macros. It has
its own macros.

The dynamic fields used __dynamic_array() to be created, but the output is
different than the __dynamic_array() used by TRACE_EVENT().

The TRACE_EVENT() __dynamic_array() creates the field like:

	field:__data_loc u8[] v_data;   offset:120;     size:4; signed:0;

Whereas the ftrace event is created as:

	field:char buf[];       offset:12;      size:0; signed:0;

The difference is that the ftrace field is defined as the rest of the size
of the event saved in the ring buffer. TRACE_EVENT() doesn't have such a
dynamic field, and its version saves a word that holds the offset into the
event that the field is stored, as well as the size.

For consistency rename the ftrace event macro to __dynamic_field(). This
way the ftrace event can also include a __dynamic_array() later that works
the same as the TRACE_EVENT() dynamic array.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace.h         |  4 ++--
 kernel/trace/trace_entries.h | 10 +++++-----
 kernel/trace/trace_export.c  | 12 ++++++------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 5f4bed5842f9..0fd2559ff119 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -92,8 +92,8 @@ enum trace_type {
 #undef __array_desc
 #define __array_desc(type, container, item, size)
 
-#undef __dynamic_array
-#define __dynamic_array(type, item)	type	item[];
+#undef __dynamic_field
+#define __dynamic_field(type, item)	type	item[];
 
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item)	type	item[];
diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
index de294ae2c5c5..5cf80f6c704a 100644
--- a/kernel/trace/trace_entries.h
+++ b/kernel/trace/trace_entries.h
@@ -63,7 +63,7 @@ FTRACE_ENTRY_REG(function, ftrace_entry,
 	F_STRUCT(
 		__field_fn(	unsigned long,		ip		)
 		__field_fn(	unsigned long,		parent_ip	)
-		__dynamic_array( unsigned long,		args		)
+		__dynamic_field( unsigned long,		args		)
 	),
 
 	F_printk(" %ps <-- %ps",
@@ -81,7 +81,7 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
 		__field_struct(	struct ftrace_graph_ent,	graph_ent	)
 		__field_packed(	unsigned long,	graph_ent,	func		)
 		__field_packed(	unsigned int,	graph_ent,	depth		)
-		__dynamic_array(unsigned long,	args				)
+		__dynamic_field(unsigned long,	args				)
 	),
 
 	F_printk("--> %ps (%u)", (void *)__entry->func, __entry->depth)
@@ -259,7 +259,7 @@ FTRACE_ENTRY(bprint, bprint_entry,
 	F_STRUCT(
 		__field(	unsigned long,	ip	)
 		__field(	const char *,	fmt	)
-		__dynamic_array(	u32,	buf	)
+		__dynamic_field(	u32,	buf	)
 	),
 
 	F_printk("%ps: %s",
@@ -272,7 +272,7 @@ FTRACE_ENTRY_REG(print, print_entry,
 
 	F_STRUCT(
 		__field(	unsigned long,	ip	)
-		__dynamic_array(	char,	buf	)
+		__dynamic_field(	char,	buf	)
 	),
 
 	F_printk("%ps: %s",
@@ -287,7 +287,7 @@ FTRACE_ENTRY(raw_data, raw_data_entry,
 
 	F_STRUCT(
 		__field(	unsigned int,	id	)
-		__dynamic_array(	char,	buf	)
+		__dynamic_field(	char,	buf	)
 	),
 
 	F_printk("id:%04x %08x",
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 1698fc22afa0..d9d41e3ba379 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -57,8 +57,8 @@ static int ftrace_event_register(struct trace_event_call *call,
 #undef __array_desc
 #define __array_desc(type, container, item, size)	type item[size];
 
-#undef __dynamic_array
-#define __dynamic_array(type, item)			type item[];
+#undef __dynamic_field
+#define __dynamic_field(type, item)			type item[];
 
 #undef F_STRUCT
 #define F_STRUCT(args...)				args
@@ -123,8 +123,8 @@ static void __always_unused ____ftrace_check_##name(void)		\
 #undef __array_desc
 #define __array_desc(_type, _container, _item, _len) __array(_type, _item, _len)
 
-#undef __dynamic_array
-#define __dynamic_array(_type, _item) {					\
+#undef __dynamic_field
+#define __dynamic_field(_type, _item) {					\
 	.type = #_type "[]", .name = #_item,				\
 	.size = 0, .align = __alignof__(_type),				\
 	is_signed_type(_type), .filter_type = FILTER_OTHER },
@@ -161,8 +161,8 @@ static struct trace_event_fields ftrace_event_fields_##name[] = {	\
 #undef __array_desc
 #define __array_desc(type, container, item, len)
 
-#undef __dynamic_array
-#define __dynamic_array(type, item)
+#undef __dynamic_field
+#define __dynamic_field(type, item)
 
 #undef F_printk
 #define F_printk(fmt, args...) __stringify(fmt) ", "  __stringify(args)
-- 
2.50.1



  parent reply	other threads:[~2025-08-28 18:03 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28 18:03 [PATCH v6 0/6] tracing: Deferred unwinding of user space stack traces Steven Rostedt
2025-08-28 18:03 ` [PATCH v6 1/6] tracing: Do not bother getting user space stacktraces for kernel threads Steven Rostedt
2025-08-28 18:03 ` Steven Rostedt [this message]
2025-08-28 18:03 ` [PATCH v6 3/6] tracing: Implement deferred user space stacktracing Steven Rostedt
2025-08-28 18:03 ` [PATCH v6 4/6] tracing: Have deferred user space stacktrace show file offsets Steven Rostedt
2025-08-28 18:03 ` [PATCH v6 5/6] tracing: Show inode and device major:minor in deferred user space stacktrace Steven Rostedt
2025-08-28 18:39   ` Linus Torvalds
2025-08-28 18:58     ` Arnaldo Carvalho de Melo
2025-08-28 19:02       ` Mathieu Desnoyers
2025-08-28 19:18       ` Linus Torvalds
2025-08-28 20:04         ` Arnaldo Carvalho de Melo
2025-08-28 20:37           ` Linus Torvalds
2025-08-28 20:17         ` Steven Rostedt
2025-08-28 20:27           ` Arnaldo Carvalho de Melo
2025-08-28 20:42             ` Linus Torvalds
2025-08-28 20:51             ` Steven Rostedt
2025-08-28 21:00               ` Arnaldo Carvalho de Melo
2025-08-28 21:27                 ` Steven Rostedt
2025-08-29 16:27                 ` Sam James
2025-08-28 20:38           ` Linus Torvalds
2025-08-28 20:48             ` Steven Rostedt
2025-08-28 21:06               ` Linus Torvalds
2025-08-28 21:17                 ` Steven Rostedt
2025-08-28 22:10                   ` Linus Torvalds
2025-08-28 22:44                     ` Steven Rostedt
2025-08-29 15:06                     ` Steven Rostedt
2025-08-29 15:47                       ` Linus Torvalds
2025-08-29 16:07                         ` Linus Torvalds
2025-08-29 16:33                           ` Steven Rostedt
2025-08-29 16:42                             ` Linus Torvalds
2025-08-29 16:50                               ` Linus Torvalds
2025-08-29 17:02                                 ` Steven Rostedt
2025-08-29 17:13                                   ` Linus Torvalds
2025-08-29 17:57                                     ` Arnaldo Carvalho de Melo
2025-08-29 20:51                                       ` Linus Torvalds
2025-08-29 16:57                               ` Steven Rostedt
2025-08-29 17:02                                 ` Linus Torvalds
2025-08-29 17:52                                   ` Steven Rostedt
2025-08-29 16:19                         ` Steven Rostedt
2025-08-29 16:28                           ` Linus Torvalds
2025-08-29 16:49                             ` Steven Rostedt
2025-08-29 16:59                               ` Linus Torvalds
2025-08-29 17:17                                 ` Arnaldo Carvalho de Melo
2025-08-29 17:33                                   ` Linus Torvalds
2025-08-29 18:11                                     ` Steven Rostedt
2025-08-29 20:54                                       ` Linus Torvalds
2025-08-29 21:18                                         ` Steven Rostedt
2025-08-29 22:40                                           ` Linus Torvalds
2025-08-29 23:09                                             ` Steven Rostedt
2025-08-29 23:42                                               ` Steven Rostedt
2025-08-30  0:36                                                 ` Steven Rostedt
2025-08-30  0:44                                               ` Steven Rostedt
2025-08-30  0:45                                               ` Linus Torvalds
2025-08-30  1:20                                                 ` Steven Rostedt
2025-08-30  1:26                                                   ` Steven Rostedt
2025-08-30 18:31                                                 ` Steven Rostedt
2025-08-30 19:03                                                   ` Arnaldo Carvalho de Melo
2025-08-30 19:03                                                   ` Linus Torvalds
2025-08-28 18:03 ` [PATCH v6 6/6] tracing: Add an event to map the inodes to their file names 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=20250828180356.716157474@kernel.org \
    --to=rostedt@kernel.org \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=beaub@linux.microsoft.com \
    --cc=bpf@vger.kernel.org \
    --cc=codonell@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=indu.bhagat@oracle.com \
    --cc=jemarch@gnu.org \
    --cc=jolsa@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=jremus@linux.ibm.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sam@gentoo.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).