From: "Thomas Weißschuh (Schneider Electric)" <thomas.weissschuh@linutronix.de>
To: Jan Kiszka <jan.kiszka@siemens.com>,
Kieran Bingham <kbingham@kernel.org>,
John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Frederic Weisbecker <frederic@kernel.org>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
"Thomas Weißschuh (Schneider Electric)"
<thomas.weissschuh@linutronix.de>
Subject: [PATCH 02/12] tracing: Use explicit array size instead of sentinel elements in symbol printing
Date: Wed, 11 Mar 2026 11:15:11 +0100 [thread overview]
Message-ID: <20260311-hrtimer-cleanups-v1-2-095357392669@linutronix.de> (raw)
In-Reply-To: <20260311-hrtimer-cleanups-v1-0-095357392669@linutronix.de>
The sentinel value added by the wrapper macros __print_symbolic() et al
prevents the callers from adding their own trailing comma. This makes
constructing symbol list dynamically based on kconfig values tedious.
Drop the sentinel elements, so callers can either specify the trailing
comma or not, just like in regular array initializers.
Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
---
include/linux/trace_events.h | 13 ++++++----
include/trace/stages/stage3_trace_output.h | 40 +++++++++++++++---------------
kernel/trace/trace_events_synth.c | 4 +--
kernel/trace/trace_output.c | 20 +++++++++------
kernel/trace/trace_syscalls.c | 3 +--
5 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 37eb2f0f3dd8..40a43a4c7caf 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -22,20 +22,23 @@ union bpf_attr;
const char *trace_print_flags_seq(struct trace_seq *p, const char *delim,
unsigned long flags,
- const struct trace_print_flags *flag_array);
+ const struct trace_print_flags *flag_array,
+ size_t flag_array_size);
const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
- const struct trace_print_flags *symbol_array);
+ const struct trace_print_flags *symbol_array,
+ size_t symbol_array_size);
#if BITS_PER_LONG == 32
const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
unsigned long long flags,
- const struct trace_print_flags_u64 *flag_array);
+ const struct trace_print_flags_u64 *flag_array,
+ size_t flag_array_size);
const char *trace_print_symbols_seq_u64(struct trace_seq *p,
unsigned long long val,
- const struct trace_print_flags_u64
- *symbol_array);
+ const struct trace_print_flags_u64 *symbol_array,
+ size_t symbol_array_size);
#endif
struct trace_iterator;
diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h
index fce85ea2df1c..b7d8ef4b9fe1 100644
--- a/include/trace/stages/stage3_trace_output.h
+++ b/include/trace/stages/stage3_trace_output.h
@@ -64,36 +64,36 @@
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
#undef __print_flags
-#define __print_flags(flag, delim, flag_array...) \
- ({ \
- static const struct trace_print_flags __flags[] = \
- { flag_array, { -1, NULL }}; \
- trace_print_flags_seq(p, delim, flag, __flags); \
+#define __print_flags(flag, delim, flag_array...) \
+ ({ \
+ static const struct trace_print_flags __flags[] = \
+ { flag_array }; \
+ trace_print_flags_seq(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \
})
#undef __print_symbolic
-#define __print_symbolic(value, symbol_array...) \
- ({ \
- static const struct trace_print_flags symbols[] = \
- { symbol_array, { -1, NULL }}; \
- trace_print_symbols_seq(p, value, symbols); \
+#define __print_symbolic(value, symbol_array...) \
+ ({ \
+ static const struct trace_print_flags symbols[] = \
+ { symbol_array }; \
+ trace_print_symbols_seq(p, value, symbols, ARRAY_SIZE(symbols)); \
})
#undef __print_flags_u64
#undef __print_symbolic_u64
#if BITS_PER_LONG == 32
-#define __print_flags_u64(flag, delim, flag_array...) \
- ({ \
- static const struct trace_print_flags_u64 __flags[] = \
- { flag_array, { -1, NULL } }; \
- trace_print_flags_seq_u64(p, delim, flag, __flags); \
+#define __print_flags_u64(flag, delim, flag_array...) \
+ ({ \
+ static const struct trace_print_flags_u64 __flags[] = \
+ { flag_array }; \
+ trace_print_flags_seq_u64(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \
})
-#define __print_symbolic_u64(value, symbol_array...) \
- ({ \
- static const struct trace_print_flags_u64 symbols[] = \
- { symbol_array, { -1, NULL } }; \
- trace_print_symbols_seq_u64(p, value, symbols); \
+#define __print_symbolic_u64(value, symbol_array...) \
+ ({ \
+ static const struct trace_print_flags_u64 symbols[] = \
+ { symbol_array }; \
+ trace_print_symbols_seq_u64(p, value, symbols, ARRAY_SIZE(symbols)); \
})
#else
#define __print_flags_u64(flag, delim, flag_array...) \
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 8bb95b2a6fcf..39ac4eba0702 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -395,7 +395,7 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
n_u64++;
} else {
struct trace_print_flags __flags[] = {
- __def_gfpflag_names, {-1, NULL} };
+ __def_gfpflag_names };
char *space = (i == se->n_fields - 1 ? "" : " ");
print_synth_event_num_val(s, print_fmt,
@@ -408,7 +408,7 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
trace_seq_puts(s, " (");
trace_print_flags_seq(s, "|",
entry->fields[n_u64].as_u64,
- __flags);
+ __flags, ARRAY_SIZE(__flags));
trace_seq_putc(s, ')');
}
n_u64++;
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 1996d7aba038..96e2d22b4364 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -69,14 +69,15 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
const char *
trace_print_flags_seq(struct trace_seq *p, const char *delim,
unsigned long flags,
- const struct trace_print_flags *flag_array)
+ const struct trace_print_flags *flag_array,
+ size_t flag_array_size)
{
unsigned long mask;
const char *str;
const char *ret = trace_seq_buffer_ptr(p);
int i, first = 1;
- for (i = 0; flag_array[i].name && flags; i++) {
+ for (i = 0; i < flag_array_size && flags; i++) {
mask = flag_array[i].mask;
if ((flags & mask) != mask)
@@ -106,12 +107,13 @@ EXPORT_SYMBOL(trace_print_flags_seq);
const char *
trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
- const struct trace_print_flags *symbol_array)
+ const struct trace_print_flags *symbol_array,
+ size_t symbol_array_size)
{
int i;
const char *ret = trace_seq_buffer_ptr(p);
- for (i = 0; symbol_array[i].name; i++) {
+ for (i = 0; i < symbol_array_size; i++) {
if (val != symbol_array[i].mask)
continue;
@@ -133,14 +135,15 @@ EXPORT_SYMBOL(trace_print_symbols_seq);
const char *
trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
unsigned long long flags,
- const struct trace_print_flags_u64 *flag_array)
+ const struct trace_print_flags_u64 *flag_array,
+ size_t flag_array_size)
{
unsigned long long mask;
const char *str;
const char *ret = trace_seq_buffer_ptr(p);
int i, first = 1;
- for (i = 0; flag_array[i].name && flags; i++) {
+ for (i = 0; i < flag_array_size && flags; i++) {
mask = flag_array[i].mask;
if ((flags & mask) != mask)
@@ -170,12 +173,13 @@ EXPORT_SYMBOL(trace_print_flags_seq_u64);
const char *
trace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
- const struct trace_print_flags_u64 *symbol_array)
+ const struct trace_print_flags_u64 *symbol_array,
+ size_t symbol_array_size)
{
int i;
const char *ret = trace_seq_buffer_ptr(p);
- for (i = 0; symbol_array[i].name; i++) {
+ for (i = 0; i < symbol_array_size; i++) {
if (val != symbol_array[i].mask)
continue;
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 37317b81fcda..8ad72e17d8eb 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -174,7 +174,6 @@ sys_enter_openat_print(struct syscall_trace_enter *trace, struct syscall_metadat
{ O_NOFOLLOW, "O_NOFOLLOW" },
{ O_NOATIME, "O_NOATIME" },
{ O_CLOEXEC, "O_CLOEXEC" },
- { -1, NULL }
};
trace_seq_printf(s, "%s(", entry->name);
@@ -205,7 +204,7 @@ sys_enter_openat_print(struct syscall_trace_enter *trace, struct syscall_metadat
trace_seq_puts(s, "O_RDONLY|");
}
- trace_print_flags_seq(s, "|", bits, __flags);
+ trace_print_flags_seq(s, "|", bits, __flags, ARRAY_SIZE(__flags));
/*
* trace_print_flags_seq() adds a '\0' to the
* buffer, but this needs to append more to the seq.
--
2.53.0
next prev parent reply other threads:[~2026-03-11 10:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 10:15 [PATCH 00/12] hrtimer, timekeeping, tracing: various cleanups Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 01/12] scripts/gdb: timerlist: Adapt to move of tk_core Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` Thomas Weißschuh (Schneider Electric) [this message]
2026-03-12 11:25 ` [tip: timers/core] tracing: Use explicit array size instead of sentinel elements in symbol printing tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 03/12] timer_list: Print offset as signed integer Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 04/12] timekeeping: auxclock: Consistently use raw timekeeper for tk_setup_internals() Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] timekeeping/auxclock: " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 05/12] timekeeping: Mark offsets array as const Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 06/12] hrtimer: Remove hrtimer_get_expires_ns() Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 07/12] hrtimer: Don't zero-initialize ret in hrtimer_nanosleep() Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 08/12] hrtimer: Drop spurious space in 'enum hrtimer_base_type' Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 09/12] hrtimer: Drop unnecessary pointer indirection in hrtimer_expire_entry event Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 10/12] hrtimer: Mark index and clockid of clock base as const Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 11/12] hrtimer: Remove trailing comma after HRTIMER_MAX_CLOCK_BASES Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-03-11 10:15 ` [PATCH 12/12] hrtimer: Add a helper to retrieve a hrtimer from its timerqueue node Thomas Weißschuh (Schneider Electric)
2026-03-12 11:25 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
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=20260311-hrtimer-cleanups-v1-2-095357392669@linutronix.de \
--to=thomas.weissschuh@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jan.kiszka@siemens.com \
--cc=jstultz@google.com \
--cc=kbingham@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=rostedt@goodmis.org \
--cc=sboyd@kernel.org \
--cc=tglx@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
all inboxes | Powered by JetHome®