* [for-next][PATCH 0/8] tracing: Updates for v7.5
@ 2026-12-02 8:14 Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 1/8] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events Steven Rostedt
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next
Head SHA1: 175e5f3eddc62c5ad286dc0cc0fb56e2d02d8fa4
Jaewon Jung (1):
tracing: Use test_bit() in event_enable_count_probe()
Johannes Berg (3):
tracing: Add __print_sym() to replace __print_symbolic()
net: dropreason: use new __print_sym() in tracing
net: drop_monitor: use drop_reason_lookup()
Karl Mehltretter (1):
tracing: Don't use TRACE_BRANCH_BIT as a mask
Mingbing Zhai (1):
tracing: Drop duplicated NO_CMDLINE_MAP check in saved_cmdlines_next()
Steven Rostedt (2):
tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events
tracing: Do not bother getting user space stacktraces for kernel threads
----
include/asm-generic/vmlinux.lds.h | 4 +
include/linux/module.h | 2 +
include/linux/trace_events.h | 7 ++
include/linux/tracepoint.h | 20 ++++
include/net/dropreason.h | 8 +-
include/trace/events/skb.h | 13 +--
include/trace/stages/init.h | 55 +++++++++++
include/trace/stages/stage2_data_offsets.h | 6 ++
include/trace/stages/stage3_trace_output.h | 9 ++
include/trace/stages/stage7_class_define.h | 3 +
kernel/module/main.c | 3 +
kernel/trace/trace.c | 4 +
kernel/trace/trace.h | 4 +-
kernel/trace/trace_branch.c | 6 +-
kernel/trace/trace_entries.h | 12 +--
kernel/trace/trace_events.c | 102 ++++++++++++++++++++-
kernel/trace/trace_export.c | 12 +--
kernel/trace/trace_output.c | 45 +++++++++
kernel/trace/trace_sched_switch.c | 2 +-
net/core/drop_monitor.c | 20 +---
net/core/skbuff.c | 47 +++++++++-
samples/trace_events/trace-events-sample.c | 30 ++++++
samples/trace_events/trace-events-sample.h | 47 +++++++++-
.../selftests/net/openvswitch/openvswitch.sh | 17 +---
24 files changed, 413 insertions(+), 65 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [for-next][PATCH 1/8] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 2/8] tracing: Do not bother getting user space stacktraces for kernel threads Steven Rostedt
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton
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.
Link: https://patch.msgid.link/20261130144941.27cdb72d@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.h | 4 ++--
kernel/trace/trace_entries.h | 12 ++++++------
kernel/trace/trace_export.c | 12 ++++++------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 2efb580d7a15..ff08474d6e79 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -97,8 +97,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 54417468fdeb..4981f21267a7 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_desc_packed(unsigned long, graph_ent, func )
__field_desc_packed(unsigned long, graph_ent, depth )
- __dynamic_array(unsigned long, args )
+ __dynamic_field(unsigned long, args )
),
F_printk("--> %ps (%lu)", (void *)__entry->func, __entry->depth)
@@ -99,7 +99,7 @@ FTRACE_ENTRY_PACKED(fgraph_retaddr_entry, fgraph_retaddr_ent_entry,
__field_desc_packed( unsigned long, graph_rent.ent, func )
__field_desc_packed( unsigned long, graph_rent.ent, depth )
__field_desc_packed( unsigned long, graph_rent, retaddr )
- __dynamic_array(unsigned long, args )
+ __dynamic_field(unsigned long, args )
),
F_printk("--> %ps (%lu) <- %ps", (void *)__entry->func, __entry->depth,
@@ -260,7 +260,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",
@@ -273,7 +273,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",
@@ -288,7 +288,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 32a42ef31855..f0060bea2dad 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -60,8 +60,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
@@ -129,8 +129,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 },
@@ -170,8 +170,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.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 2/8] tracing: Do not bother getting user space stacktraces for kernel threads
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 1/8] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 3/8] tracing: Drop duplicated NO_CMDLINE_MAP check in saved_cmdlines_next() Steven Rostedt
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton
From: Steven Rostedt <rostedt@goodmis.org>
If a user space stacktrace is requested when running a kernel thread, just
return, as there's no point trying to get the user space stacktrace as
there is no user space.
Link: https://patch.msgid.link/20261130145215.347d42c0@gandalf.local.home
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 926a2eb247df..181b565786a9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2280,6 +2280,10 @@ ftrace_trace_userstack(struct trace_array *tr,
if (!(tr->trace_flags & TRACE_ITER(USERSTACKTRACE)))
return;
+ /* No point doing user space stacktraces on kernel threads */
+ if (!is_user_task(current))
+ return;
+
/*
* NMIs can not handle page faults, even with fix ups.
* The save user stack can (and often does) fault.
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 3/8] tracing: Drop duplicated NO_CMDLINE_MAP check in saved_cmdlines_next()
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 1/8] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 2/8] tracing: Do not bother getting user space stacktraces for kernel threads Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 4/8] tracing: Add __print_sym() to replace __print_symbolic() Steven Rostedt
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton, Mingbing Zhai
From: Mingbing Zhai <zhaimingbing@cmss.chinamobile.com>
NO_CMDLINE_MAP is defined as UINT_MAX, so "*ptr == -1" and
"*ptr == NO_CMDLINE_MAP" compare the same value: the signed -1
converts to UINT_MAX in the unsigned comparison. gcc -Wlogical-op
flags the duplicated condition. Drop the magic number and keep the
symbolic name, which is what the rest of the file uses.
Link: https://patch.msgid.link/20261126081103.4224-1-zhaimingbing@cmss.chinamobile.com
Signed-off-by: Mingbing Zhai <zhaimingbing@cmss.chinamobile.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_sched_switch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 1bd351c1fbfb..de58ff1046ec 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -526,7 +526,7 @@ static void *saved_cmdlines_next(struct seq_file *m, void *v, loff_t *pos)
for (; ptr < &savedcmd->map_cmdline_to_pid[savedcmd->cmdline_num];
ptr++) {
- if (*ptr == -1 || *ptr == NO_CMDLINE_MAP)
+ if (*ptr == NO_CMDLINE_MAP)
continue;
return ptr;
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 4/8] tracing: Add __print_sym() to replace __print_symbolic()
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
` (2 preceding siblings ...)
2026-12-02 8:14 ` [for-next][PATCH 3/8] tracing: Drop duplicated NO_CMDLINE_MAP check in saved_cmdlines_next() Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 5/8] net: dropreason: use new __print_sym() in tracing Steven Rostedt
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton, Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
The way __print_symbolic() works is limited and inefficient
in multiple ways:
- you can only use it with a static list of symbols, but
e.g. the SKB dropreasons are now a dynamic list
- it builds the list in memory _three_ times, so it takes
a lot of memory:
- The print_fmt contains the list (since it's passed to
the macro there). This actually contains the names
_twice_, which is fixed up at runtime.
- TRACE_DEFINE_ENUM() puts a 24-byte struct trace_eval_map
for every entry, plus the string pointed to by it, which
cannot be deduplicated with the strings in the print_fmt
- The in-kernel symbolic printing creates yet another list
of struct trace_print_flags for trace_print_symbols_seq()
- it also requires runtime fixup during init, which is a lot
of string parsing due to the print_fmt fixup
Introduce __print_sym() to - over time - replace the old one.
We can easily extend this also to __print_flags later, but I
cared only about the SKB dropreasons for now, which has only
__print_symbolic().
This new __print_sym() requires only a single list of items,
created by TRACE_DEFINE_SYM_LIST(), or can even use another
already existing list by using TRACE_DEFINE_SYM_FNS() with
lookup and show methods.
Then, instead of doing an init-time fixup, just do this at the
time when userspace reads the print_fmt. This way, dynamically
updated lists are possible.
For userspace, nothing actually changes, because the print_fmt
is shown exactly the same way the old __print_symbolic() was.
This adds about 4k .text in my test builds, but that'll be
more than paid for by the actual conversions.
Link: https://patch.msgid.link/20261119155133.355849-7-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/asm-generic/vmlinux.lds.h | 4 +
include/linux/module.h | 2 +
include/linux/trace_events.h | 7 ++
include/linux/tracepoint.h | 20 +++++
include/trace/stages/init.h | 55 ++++++++++++
include/trace/stages/stage2_data_offsets.h | 6 ++
include/trace/stages/stage3_trace_output.h | 9 ++
include/trace/stages/stage7_class_define.h | 3 +
kernel/module/main.c | 3 +
kernel/trace/trace_events.c | 99 +++++++++++++++++++++-
kernel/trace/trace_output.c | 45 ++++++++++
samples/trace_events/trace-events-sample.c | 30 +++++++
samples/trace_events/trace-events-sample.h | 47 +++++++++-
13 files changed, 327 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 3eb732942d69..ba2d8234aecb 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -275,9 +275,12 @@
#define FTRACE_EVENTS() \
. = ALIGN(8); \
BOUNDED_SECTION(_ftrace_events) \
+ . = ALIGN(8); \
BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps)
+#define FTRACE_SYM_DEFS() BOUNDED_SECTION(_ftrace_sym_defs)
#else
#define FTRACE_EVENTS()
+#define FTRACE_SYM_DEFS()
#endif
#ifdef CONFIG_TRACING
@@ -391,6 +394,7 @@
TRACE_PRINTKS() \
BPF_RAW_TP() \
TRACEPOINT_STR() \
+ FTRACE_SYM_DEFS() \
KUNIT_TABLE()
/*
diff --git a/include/linux/module.h b/include/linux/module.h
index e4c39013f414..ac4255fa00a5 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -522,6 +522,8 @@ struct module {
unsigned int num_trace_events;
struct trace_eval_map **trace_evals;
unsigned int num_trace_evals;
+ struct trace_sym_def **trace_sym_defs;
+ unsigned int num_trace_sym_defs;
#endif
#ifdef CONFIG_DYNAMIC_FTRACE
unsigned int num_ftrace_callsites;
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 321f2f3a6c8e..793fc1d7030a 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -29,6 +29,13 @@ const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
const struct trace_print_flags *symbol_array,
size_t symbol_array_size);
+const char *trace_print_sym_seq(struct trace_seq *p, unsigned long long val,
+ const char *(*lookup)(unsigned long long val));
+const char *trace_sym_lookup(const struct trace_sym_entry *list,
+ size_t len, unsigned long long value);
+void trace_sym_show(struct seq_file *m,
+ const struct trace_sym_entry *list, size_t len);
+
#if BITS_PER_LONG == 32
const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
unsigned long long flags,
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 7b3ee936a8ca..4303196ea9b4 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -32,6 +32,24 @@ struct trace_eval_map {
unsigned long eval_value;
};
+struct trace_sym_def {
+ const char *system;
+ const char *symbol_id;
+ /* may return NULL, called under rcu_read_lock() */
+ const char * (*lookup)(unsigned long long);
+ /*
+ * Must print the list: ', { val, "name"}, ...'
+ * with no trailing comma, but with the leading ', '
+ * to simplify things:
+ */
+ void (*show)(struct seq_file *);
+};
+
+struct trace_sym_entry {
+ unsigned long long value;
+ const char *name;
+};
+
#define TRACEPOINT_DEFAULT_PRIO 10
extern int
@@ -163,6 +181,8 @@ extern void syscall_unregfunc(void);
#define TRACE_DEFINE_ENUM(x)
#define TRACE_DEFINE_SIZEOF(x)
+#define TRACE_DEFINE_SYM_FNS(...)
+#define TRACE_DEFINE_SYM_LIST(...)
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
diff --git a/include/trace/stages/init.h b/include/trace/stages/init.h
index 000bcfc8dd2e..03a7898cc84a 100644
--- a/include/trace/stages/init.h
+++ b/include/trace/stages/init.h
@@ -23,6 +23,61 @@ TRACE_MAKE_SYSTEM_STR();
__section("_ftrace_eval_map") \
*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
+/*
+ * Define a symbol for __print_sym by giving lookup and
+ * show functions. See &struct trace_sym_def.
+ */
+#undef TRACE_DEFINE_SYM_FNS
+#define TRACE_DEFINE_SYM_FNS(_symbol_id, _lookup, _show) \
+ _TRACE_DEFINE_SYM_FNS(TRACE_SYSTEM_VAR, _symbol_id, _lookup, _show)
+#define _TRACE_DEFINE_SYM_FNS(_system, _symbol_id, _lookup, _show) \
+ __TRACE_DEFINE_SYM_FNS(_system, _symbol_id, _lookup, _show)
+#define __TRACE_DEFINE_SYM_FNS(_system, _symbol_id, _lookup, _show) \
+ ___TRACE_DEFINE_SYM_FNS(_system ## _ ## _symbol_id, _symbol_id, \
+ _lookup, _show)
+#define ___TRACE_DEFINE_SYM_FNS(_name, _symbol_id, _lookup, _show) \
+ static struct trace_sym_def \
+ __trace_sym_def_ ## _name = { \
+ .system = TRACE_SYSTEM_STRING, \
+ .symbol_id = #_symbol_id, \
+ .lookup = _lookup, \
+ .show = _show, \
+ }; \
+ static struct trace_sym_def __used \
+ __section("_ftrace_sym_defs") \
+ *__trace_sym_def_p_ ## _name = &__trace_sym_def_ ## _name
+
+/*
+ * Define a symbol for __print_sym by giving lookup and
+ * show functions. See &struct trace_sym_def.
+ */
+#undef TRACE_DEFINE_SYM_LIST
+#define TRACE_DEFINE_SYM_LIST(_symbol_id, ...) \
+ _TRACE_DEFINE_SYM_LIST(TRACE_SYSTEM_VAR, _symbol_id, __VA_ARGS__)
+#define _TRACE_DEFINE_SYM_LIST(_system, _symbol_id, ...) \
+ __TRACE_DEFINE_SYM_LIST(_system, _symbol_id, __VA_ARGS__)
+#define __TRACE_DEFINE_SYM_LIST(_system, _symbol_id, ...) \
+ ___TRACE_DEFINE_SYM_LIST(_system ## _ ## _symbol_id, _symbol_id,\
+ __VA_ARGS__)
+#define ___TRACE_DEFINE_SYM_LIST(_name, _symbol_id, ...) \
+ static struct trace_sym_entry \
+ __trace_sym_list_ ## _name[] = { __VA_ARGS__ }; \
+ static const char * \
+ __trace_sym_lookup_ ## _name(unsigned long long value) \
+ { \
+ return trace_sym_lookup(__trace_sym_list_ ## _name, \
+ ARRAY_SIZE(__trace_sym_list_ ## _name), value); \
+ } \
+ static void \
+ __trace_sym_show_ ## _name(struct seq_file *m) \
+ { \
+ trace_sym_show(m, __trace_sym_list_ ## _name, \
+ ARRAY_SIZE(__trace_sym_list_ ## _name)); \
+ } \
+ ___TRACE_DEFINE_SYM_FNS(_name, _symbol_id, \
+ __trace_sym_lookup_ ## _name, \
+ __trace_sym_show_ ## _name)
+
#undef TRACE_DEFINE_SIZEOF
#define TRACE_DEFINE_SIZEOF(a) \
static struct trace_eval_map __used __initdata \
diff --git a/include/trace/stages/stage2_data_offsets.h b/include/trace/stages/stage2_data_offsets.h
index 8b0cff06d346..5afd9de7deb3 100644
--- a/include/trace/stages/stage2_data_offsets.h
+++ b/include/trace/stages/stage2_data_offsets.h
@@ -5,6 +5,12 @@
#undef TRACE_DEFINE_ENUM
#define TRACE_DEFINE_ENUM(a)
+#undef TRACE_DEFINE_SYM_FNS
+#define TRACE_DEFINE_SYM_FNS(_symbol_id, _lookup, _show)
+
+#undef TRACE_DEFINE_SYM_LIST
+#define TRACE_DEFINE_SYM_LIST(_symbol_id, ...)
+
#undef TRACE_DEFINE_SIZEOF
#define TRACE_DEFINE_SIZEOF(a)
diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h
index 181b81335781..eb34b43147a1 100644
--- a/include/trace/stages/stage3_trace_output.h
+++ b/include/trace/stages/stage3_trace_output.h
@@ -79,6 +79,15 @@
trace_print_symbols_seq(p, value, symbols, ARRAY_SIZE(symbols)); \
})
+#undef __print_sym
+#define __print_sym(value, symbol_id) \
+ ___print_sym(TRACE_SYSTEM_VAR, value, symbol_id)
+#define ___print_sym(sys, value, symbol_id) \
+ ____print_sym(sys, value, symbol_id)
+#define ____print_sym(sys, value, symbol_id) \
+ trace_print_sym_seq(p, value, \
+ __trace_sym_def_p_ ## sys ## _ ## symbol_id->lookup)
+
#undef __print_flags_u64
#undef __print_symbolic_u64
#if BITS_PER_LONG == 32
diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h
index 47008897a795..936b9fa08cea 100644
--- a/include/trace/stages/stage7_class_define.h
+++ b/include/trace/stages/stage7_class_define.h
@@ -45,6 +45,9 @@
#define __event_in_softirq() (REC->common_flags & 0x10)
#define __event_in_irq() (REC->common_flags & 0x18)
+#undef __print_sym
+#define __print_sym(value, symbol_id) __print_sym(value:symbol_id)
+
/*
* The below is not executed in the kernel. It is only what is
* displayed in the print format for userspace to parse.
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 630431b1b16c..3e774a0caadf 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2751,6 +2751,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
mod->trace_evals = section_objs(info, "_ftrace_eval_map",
sizeof(*mod->trace_evals),
&mod->num_trace_evals);
+ mod->trace_sym_defs = section_objs(info, "_ftrace_sym_defs",
+ sizeof(*mod->trace_sym_defs),
+ &mod->num_trace_sym_defs);
#endif
#ifdef CONFIG_TRACING
mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7f89160aeff3..ebf712d7de35 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2148,6 +2148,102 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
return node;
}
+extern struct trace_sym_def *__start_ftrace_sym_defs[];
+extern struct trace_sym_def *__stop_ftrace_sym_defs[];
+
+/* note: @name is not NUL-terminated */
+static void show_sym_list(struct seq_file *m, struct trace_event_call *call,
+ const char *name, unsigned int name_len)
+{
+ struct trace_sym_def **sym_defs;
+ unsigned int n_sym_defs, i;
+
+ if ((call->flags & TRACE_EVENT_FL_DYNAMIC) || !call->module) {
+ sym_defs = __start_ftrace_sym_defs;
+ n_sym_defs = __stop_ftrace_sym_defs - __start_ftrace_sym_defs;
+ } else {
+#ifdef CONFIG_MODULES
+ struct module *mod = call->module;
+
+ sym_defs = mod->trace_sym_defs;
+ n_sym_defs = mod->num_trace_sym_defs;
+#else
+ return;
+#endif /* CONFIG_MODULES */
+ }
+
+ for (i = 0; i < n_sym_defs; i++) {
+ unsigned int sym_len;
+
+ if (!sym_defs[i])
+ continue;
+ if (sym_defs[i]->system != call->class->system)
+ continue;
+ sym_len = strlen(sym_defs[i]->symbol_id);
+ if (name_len != sym_len)
+ continue;
+ if (strncmp(sym_defs[i]->symbol_id, name, sym_len))
+ continue;
+ if (sym_defs[i]->show)
+ sym_defs[i]->show(m);
+ break;
+ }
+}
+
+static void show_print_fmt(struct seq_file *m, struct trace_event_call *call)
+{
+ char *ptr = call->print_fmt;
+ bool in_print_sym = false;
+ int quote = 0;
+
+ seq_puts(m, "\nprint fmt: ");
+ while (*ptr) {
+ if (*ptr == '\\') {
+ seq_putc(m, *ptr);
+ ptr++;
+ /* paranoid */
+ if (!*ptr)
+ break;
+ goto next;
+ }
+ if (*ptr == '"') {
+ quote ^= 1;
+ goto next;
+ }
+ if (quote)
+ goto next;
+
+ if (in_print_sym && *ptr != ':')
+ goto next;
+
+ if (in_print_sym && *ptr == ':') {
+ const char *name;
+
+ ptr++;
+ name = ptr;
+ /* skip the name */
+ while (*ptr && *ptr != ')')
+ ptr++;
+ /* and show the actual list inline now */
+ show_sym_list(m, call, name, ptr - name);
+ in_print_sym = false;
+ continue;
+ }
+
+ if (strncmp(ptr, "__print_sym(", 12) == 0) {
+ ptr += 12;
+ seq_puts(m, "__print_symbolic(");
+ in_print_sym = true;
+ continue;
+ }
+next:
+ seq_putc(m, *ptr);
+ ptr++;
+ }
+
+ seq_putc(m, '\n');
+}
+
static int f_show(struct seq_file *m, void *v)
{
struct trace_event_file *file = event_file_data(m->private);
@@ -2167,8 +2263,7 @@ static int f_show(struct seq_file *m, void *v)
return 0;
case FORMAT_PRINTFMT:
- seq_printf(m, "\nprint fmt: %s\n",
- call->print_fmt);
+ show_print_fmt(m, call);
return 0;
}
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index a5ad76175d10..0850b3ad5707 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -131,6 +131,51 @@ trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
}
EXPORT_SYMBOL(trace_print_symbols_seq);
+const char *trace_sym_lookup(const struct trace_sym_entry *list,
+ size_t len, unsigned long long value)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (list[i].value == value)
+ return list[i].name;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL(trace_sym_lookup);
+
+void trace_sym_show(struct seq_file *m,
+ const struct trace_sym_entry *list, size_t len)
+{
+ size_t i;
+
+ for (i = 0; i < len; i++)
+ seq_printf(m, ", { %lld, \"%s\" }",
+ list[i].value, list[i].name);
+}
+EXPORT_SYMBOL(trace_sym_show);
+
+const char *
+trace_print_sym_seq(struct trace_seq *p, unsigned long long val,
+ const char *(*lookup)(unsigned long long val))
+{
+ const char *ret = trace_seq_buffer_ptr(p);
+ const char *name;
+
+ rcu_read_lock();
+ name = lookup(val);
+ if (name)
+ trace_seq_puts(p, name);
+ else
+ trace_seq_printf(p, "0x%llx", val);
+ rcu_read_unlock();
+
+ trace_seq_putc(p, 0);
+
+ return ret;
+}
+EXPORT_SYMBOL(trace_print_sym_seq);
+
#if BITS_PER_LONG == 32
const char *
trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c
index 0164cbdc4263..61a70087798a 100644
--- a/samples/trace_events/trace-events-sample.c
+++ b/samples/trace_events/trace-events-sample.c
@@ -11,6 +11,36 @@
#define CREATE_TRACE_POINTS
#include "trace-events-sample.h"
+/* functions for the dynamic __print_sym() example */
+static const struct {
+ unsigned long val;
+ char *name;
+} print_sym_dynamic_names[] = {
+ { 0, "zero" },
+ { TRACE_SAMPLE_FOO, "TWO" },
+ { TRACE_SAMPLE_BAR, "FOUR" },
+ { TRACE_SAMPLE_ZOO, "EIGHT" },
+ { 10, "TEN" }
+};
+
+const char *sample_names_dynamic_lookup(unsigned long long value)
+{
+ for (int i = 0; i < ARRAY_SIZE(print_sym_dynamic_names); i++) {
+ if (print_sym_dynamic_names[i].val == value)
+ return print_sym_dynamic_names[i].name;
+ }
+
+ return NULL;
+}
+
+void sample_names_dynamic_show(struct seq_file *m)
+{
+ for (int i = 0; i < ARRAY_SIZE(print_sym_dynamic_names); i++)
+ seq_printf(m, ", { %lu, \"%s\" }",
+ print_sym_dynamic_names[i].val,
+ print_sym_dynamic_names[i].name);
+}
+
static const char *random_strings[] = {
"Mother Goose",
"Snoopy",
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h
index 021fd0e9d2f5..8cda753f8ed0 100644
--- a/samples/trace_events/trace-events-sample.h
+++ b/samples/trace_events/trace-events-sample.h
@@ -297,6 +297,33 @@ TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO);
TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR);
TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO);
+/*
+ * define the names as { value, "name" } tuples for __print_sym() below,
+ * same as the inline list for __print_dynamic()
+ */
+TRACE_DEFINE_SYM_LIST(sample_names_static,
+ { 0, "zero" },
+ { TRACE_SAMPLE_FOO, "TWO" },
+ { TRACE_SAMPLE_BAR, "FOUR" },
+ { TRACE_SAMPLE_ZOO, "EIGHT" },
+ { 10, "TEN" }
+);
+
+/*
+ * Alternatively, you could define a function for the names:
+ *
+ * The _lookup() function returns the string for the given value.
+ *
+ * The _show() function must
+ * seq_printf(m, ", { %u, \"%s\" }", value, name);
+ * for each value that userspace should be able to parse.
+ */
+const char *sample_names_dynamic_lookup(unsigned long long value);
+void sample_names_dynamic_show(struct seq_file *m);
+TRACE_DEFINE_SYM_FNS(sample_names_dynamic,
+ sample_names_dynamic_lookup,
+ sample_names_dynamic_show);
+
TRACE_EVENT(foo_bar,
TP_PROTO(const char *foo, int bar, const int *lst,
@@ -328,7 +355,7 @@ TRACE_EVENT(foo_bar,
__assign_cpumask(cpum, cpumask_bits(mask));
),
- TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s [%d] %*pbl",
+ TP_printk("foo %s %d %s %s %s %s %s %s %s %s (%s) (%s) %s [%d] %*pbl",
__entry->foo, __entry->bar,
/*
@@ -340,6 +367,9 @@ TRACE_EVENT(foo_bar,
* the variable matches one of the values, then it will print the
* string in that pair. If non are matched, it returns a string
* version of the number (if __entry->bar == 7 then "7" is returned).
+ *
+ * NOTE: This variant is deprecated, it uses more space than the below
+ * __print_sym() which is identical to this for userspace.
*/
__print_symbolic(__entry->bar,
{ 0, "zero" },
@@ -349,6 +379,21 @@ TRACE_EVENT(foo_bar,
{ 10, "TEN" }
),
+/*
+ * __print_sym( variable, symbol_list_definition ),
+ *
+ * The variable is tested against each value of the symbol list.
+ * The symbol list can be built statically (sample_names_static) or
+ * dynamically (sample_names_dynamic). If the variable matches one
+ * of the values, then it will print the string in that pair. If
+ * no entry matches, the number itself is printed (e.g. here if
+ * if __entry->bar == 7 then "7" is shown).
+ *
+ * See above for the declaration of sample_names_{static,dynamic}.
+ */
+ __print_sym(__entry->bar, sample_names_static),
+ __print_sym(__entry->bar, sample_names_dynamic),
+
/*
* __print_flags( variable, "delim", { value, "flag" }, ... ),
*
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 5/8] net: dropreason: use new __print_sym() in tracing
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
` (3 preceding siblings ...)
2026-12-02 8:14 ` [for-next][PATCH 4/8] tracing: Add __print_sym() to replace __print_symbolic() Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 6/8] net: drop_monitor: use drop_reason_lookup() Steven Rostedt
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton, Johannes Berg,
Ilya Maximets
From: Johannes Berg <johannes.berg@intel.com>
The __print_symbolic() could only ever print the core
drop reasons, since that's the way the infrastructure
works. Now that we have __print_sym() with all the
advantages mentioned in that commit, convert to that
and get all the drop reasons from all subsystems. As
we already have a list of them, that's really easy.
This is a little bit of .text (~100 bytes in my build)
and saves a lot of .data (~17k).
Link: https://patch.msgid.link/20261119155133.355849-9-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/net/dropreason.h | 5 +++
include/trace/events/skb.h | 13 ++----
net/core/skbuff.c | 43 +++++++++++++++++++
.../selftests/net/openvswitch/openvswitch.sh | 17 ++------
4 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index 1df60645fb27..dc4a60130c09 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -42,6 +42,11 @@ struct drop_reason_list {
extern const struct drop_reason_list __rcu *
drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM];
+#ifdef CONFIG_TRACEPOINTS
+const char *drop_reason_lookup(unsigned long long value);
+void drop_reason_show(struct seq_file *m);
+#endif
+
void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys,
const struct drop_reason_list *list);
void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys);
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 2945aa7fe9a7..991bf172a6ea 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -8,15 +8,9 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/tracepoint.h>
+#include <net/dropreason.h>
-#undef FN
-#define FN(reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason);
-DEFINE_DROP_REASON(FN, FN)
-
-#undef FN
-#undef FNe
-#define FN(reason) { SKB_DROP_REASON_##reason, #reason },
-#define FNe(reason) { SKB_DROP_REASON_##reason, #reason }
+TRACE_DEFINE_SYM_FNS(drop_reason, drop_reason_lookup, drop_reason_show);
/*
* Tracepoint for free an sk_buff:
@@ -47,8 +41,7 @@ TRACE_EVENT(kfree_skb,
TP_printk("skbaddr=%p rx_sk=%p protocol=%u location=%pS reason: %s",
__entry->skbaddr, __entry->rx_sk, __entry->protocol,
__entry->location,
- __print_symbolic(__entry->reason,
- DEFINE_DROP_REASON(FN, FNe)))
+ __print_sym(__entry->reason, drop_reason))
);
#undef FN
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 74e9a96bc5df..47292611dd27 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -155,6 +155,49 @@ drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
};
EXPORT_SYMBOL(drop_reasons_by_subsys);
+#ifdef CONFIG_TRACEPOINTS
+const char *drop_reason_lookup(unsigned long long value)
+{
+ unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT;
+ u32 reason = value & ~SKB_DROP_REASON_SUBSYS_MASK;
+ const struct drop_reason_list *subsys;
+
+ if (subsys_id >= SKB_DROP_REASON_SUBSYS_NUM)
+ return NULL;
+
+ subsys = rcu_dereference(drop_reasons_by_subsys[subsys_id]);
+ if (!subsys)
+ return NULL;
+ if (reason >= subsys->n_reasons)
+ return NULL;
+ return subsys->reasons[reason];
+}
+
+void drop_reason_show(struct seq_file *m)
+{
+ u32 subsys_id;
+
+ rcu_read_lock();
+ for (subsys_id = 0; subsys_id < SKB_DROP_REASON_SUBSYS_NUM; subsys_id++) {
+ const struct drop_reason_list *subsys;
+ u32 i;
+
+ subsys = rcu_dereference(drop_reasons_by_subsys[subsys_id]);
+ if (!subsys)
+ continue;
+
+ for (i = 0; i < subsys->n_reasons; i++) {
+ if (!subsys->reasons[i])
+ continue;
+ seq_printf(m, ", { %u, \"%s\" }",
+ (subsys_id << SKB_DROP_REASON_SUBSYS_SHIFT) | i,
+ subsys->reasons[i]);
+ }
+ }
+ rcu_read_unlock();
+}
+#endif
+
/**
* drop_reasons_register_subsys - register another drop reason subsystem
* @subsys: the subsystem to register, must not be the core
diff --git a/tools/testing/selftests/net/openvswitch/openvswitch.sh b/tools/testing/selftests/net/openvswitch/openvswitch.sh
index 21444657a040..b5dbdfb29089 100755
--- a/tools/testing/selftests/net/openvswitch/openvswitch.sh
+++ b/tools/testing/selftests/net/openvswitch/openvswitch.sh
@@ -236,7 +236,7 @@ ovs_drop_reason_count()
local reason=$1
local perf_output=`perf script -i ${ovs_dir}/perf.data -F trace:event,trace`
- local pattern="skb:kfree_skb:.*reason: $reason"
+ local pattern="skb:kfree_skb:.*reason: $reason$"
return `echo "$perf_output" | grep "$pattern" | wc -l`
}
@@ -900,15 +900,6 @@ test_psample() {
# - drop packets and verify the right drop reason is reported
test_drop_reason() {
which perf >/dev/null 2>&1 || return $ksft_skip
- which pahole >/dev/null 2>&1 || return $ksft_skip
-
- ovs_drop_subsys=$(pahole -C skb_drop_reason_subsys |
- awk '/OPENVSWITCH/ { print $3; }' |
- tr -d ,)
- if [ -z "$ovs_drop_subsys" ]; then
- info "failed to get OVS drop subsys ID"
- return $ksft_skip
- fi
sbx_add "test_drop_reason" || return $?
@@ -952,7 +943,7 @@ test_drop_reason() {
"in_port(2),eth(),eth_type(0x0800),ipv4(src=172.31.110.20,proto=1),icmp()" 'drop'
ovs_drop_record_and_run "test_drop_reason" ip netns exec client ping -c 2 172.31.110.20
- ovs_drop_reason_count 0x${ovs_drop_subsys}0001 # OVS_DROP_FLOW_ACTION
+ ovs_drop_reason_count OVS_DROP_LAST_ACTION
if [[ "$?" -ne "2" ]]; then
info "Did not detect expected drops: $?"
return 1
@@ -969,7 +960,7 @@ test_drop_reason() {
ovs_drop_record_and_run \
"test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 6000
- ovs_drop_reason_count 0x${ovs_drop_subsys}0004 # OVS_DROP_EXPLICIT_ACTION_ERROR
+ ovs_drop_reason_count OVS_DROP_EXPLICIT_WITH_ERROR
if [[ "$?" -ne "1" ]]; then
info "Did not detect expected explicit error drops: $?"
return 1
@@ -977,7 +968,7 @@ test_drop_reason() {
ovs_drop_record_and_run \
"test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 7000
- ovs_drop_reason_count 0x${ovs_drop_subsys}0003 # OVS_DROP_EXPLICIT_ACTION
+ ovs_drop_reason_count OVS_DROP_EXPLICIT
if [[ "$?" -ne "1" ]]; then
info "Did not detect expected explicit drops: $?"
return 1
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 6/8] net: drop_monitor: use drop_reason_lookup()
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
` (4 preceding siblings ...)
2026-12-02 8:14 ` [for-next][PATCH 5/8] net: dropreason: use new __print_sym() in tracing Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 7/8] tracing: Dont use TRACE_BRANCH_BIT as a mask Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 8/8] tracing: Use test_bit() in event_enable_count_probe() Steven Rostedt
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton, Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Now that we have drop_reason_lookup(), we can just use it for
drop_monitor as well, rather than exporting the list itself.
Link: https://patch.msgid.link/20261119155133.355849-10-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/net/dropreason.h | 5 +----
net/core/drop_monitor.c | 20 +++++---------------
net/core/skbuff.c | 6 +++---
3 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index dc4a60130c09..537428c72642 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -38,12 +38,9 @@ struct drop_reason_list {
size_t n_reasons;
};
-/* Note: due to dynamic registrations, access must be under RCU */
-extern const struct drop_reason_list __rcu *
-drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM];
+const char *drop_reason_lookup(unsigned long long value);
#ifdef CONFIG_TRACEPOINTS
-const char *drop_reason_lookup(unsigned long long value);
void drop_reason_show(struct seq_file *m);
#endif
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index edc660778408..5aa7692c5df2 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -611,9 +611,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
size_t payload_len)
{
struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb);
- const struct drop_reason_list *list = NULL;
- unsigned int subsys, subsys_reason;
char buf[NET_DM_MAX_SYMBOL_LEN];
+ const char *reason_str;
struct nlattr *attr;
void *hdr;
int rc;
@@ -631,19 +630,10 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
goto nla_put_failure;
rcu_read_lock();
- subsys = u32_get_bits(cb->reason, SKB_DROP_REASON_SUBSYS_MASK);
- if (subsys < SKB_DROP_REASON_SUBSYS_NUM)
- list = rcu_dereference(drop_reasons_by_subsys[subsys]);
- subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK;
- if (!list ||
- subsys_reason >= list->n_reasons ||
- !list->reasons[subsys_reason] ||
- strlen(list->reasons[subsys_reason]) > NET_DM_MAX_REASON_LEN) {
- list = rcu_dereference(drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE]);
- subsys_reason = SKB_DROP_REASON_NOT_SPECIFIED;
- }
- if (nla_put_string(msg, NET_DM_ATTR_REASON,
- list->reasons[subsys_reason])) {
+ reason_str = drop_reason_lookup(cb->reason);
+ if (unlikely(!reason_str))
+ reason_str = drop_reason_lookup(SKB_DROP_REASON_NOT_SPECIFIED);
+ if (nla_put_string(msg, NET_DM_ATTR_REASON, reason_str)) {
rcu_read_unlock();
goto nla_put_failure;
}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 47292611dd27..3510fbbaf047 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -149,13 +149,11 @@ static const struct drop_reason_list drop_reasons_core = {
.n_reasons = ARRAY_SIZE(drop_reasons),
};
-const struct drop_reason_list __rcu *
+static const struct drop_reason_list __rcu *
drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
[SKB_DROP_REASON_SUBSYS_CORE] = RCU_INITIALIZER(&drop_reasons_core),
};
-EXPORT_SYMBOL(drop_reasons_by_subsys);
-#ifdef CONFIG_TRACEPOINTS
const char *drop_reason_lookup(unsigned long long value)
{
unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT;
@@ -172,7 +170,9 @@ const char *drop_reason_lookup(unsigned long long value)
return NULL;
return subsys->reasons[reason];
}
+EXPORT_SYMBOL(drop_reason_lookup);
+#ifdef CONFIG_TRACEPOINTS
void drop_reason_show(struct seq_file *m)
{
u32 subsys_id;
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 7/8] tracing: Dont use TRACE_BRANCH_BIT as a mask
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
` (5 preceding siblings ...)
2026-12-02 8:14 ` [for-next][PATCH 6/8] net: drop_monitor: use drop_reason_lookup() Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 8/8] tracing: Use test_bit() in event_enable_count_probe() Steven Rostedt
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton,
Karl Mehltretter
From: Karl Mehltretter <kmehltretter@gmail.com>
TRACE_BRANCH_BIT is a bit number, but the branch tracer uses it as a
mask on current->trace_recursion. Instead of its own bit, the branch
tracer tests, sets and clears bits that function tracing uses for its
own recursion protection.
While a function tracing callback holds one of these bits, the current
task's branch events are lost. This includes events in an interrupt that
arrives during the callback.
Use the trace_recursion_*() helpers, which take a bit number.
Link: https://patch.msgid.link/20261129000609.45955-1-kmehltretter@gmail.com
Fixes: 6224beb12e19 ("tracing: Have branch tracer use recursive field of task struct")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_branch.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index d8e97ad798f0..ed19e69f9294 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -38,7 +38,7 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
unsigned int trace_ctx;
const char *p;
- if (current->trace_recursion & TRACE_BRANCH_BIT)
+ if (trace_recursion_test(TRACE_BRANCH_BIT))
return;
/*
@@ -52,7 +52,7 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
return;
raw_local_irq_save(flags);
- current->trace_recursion |= TRACE_BRANCH_BIT;
+ trace_recursion_set(TRACE_BRANCH_BIT);
if (!tracer_tracing_is_on_cpu(tr, raw_smp_processor_id()))
goto out;
@@ -80,7 +80,7 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
trace_buffer_unlock_commit_nostack(buffer, event);
out:
- current->trace_recursion &= ~TRACE_BRANCH_BIT;
+ trace_recursion_clear(TRACE_BRANCH_BIT);
raw_local_irq_restore(flags);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [for-next][PATCH 8/8] tracing: Use test_bit() in event_enable_count_probe()
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
` (6 preceding siblings ...)
2026-12-02 8:14 ` [for-next][PATCH 7/8] tracing: Dont use TRACE_BRANCH_BIT as a mask Steven Rostedt
@ 2026-12-02 8:14 ` Steven Rostedt
7 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2026-12-02 8:14 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Andrew Morton, Jaewon Jung
From: Jaewon Jung <jaewon8868@gmail.com>
The ftrace callback reads SOFT_DISABLED without event_mutex while
update_event_probe() updates it with set_bit()/clear_bit(). Use test_bit()
for the lockless read.
Link: https://patch.msgid.link/20261130050252.1182166-1-jaewon8868@gmail.com
Fixes: 3cd715de2611 ("tracing: Add function probe triggers to enable/disable events")
Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ebf712d7de35..4722d9a8b222 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -4448,7 +4448,8 @@ event_enable_count_probe(unsigned long ip, unsigned long parent_ip,
return;
/* Skip if the event is in a state we want to switch to */
- if (edata->enable == !(edata->file->flags & EVENT_FILE_FL_SOFT_DISABLED))
+ if (edata->enable == !test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT,
+ &edata->file->flags))
return;
if (edata->count != -1)
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-02 8:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 8:14 [for-next][PATCH 0/8] tracing: Updates for v7.5 Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 1/8] tracing: Rename __dynamic_array() to __dynamic_field() for ftrace events Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 2/8] tracing: Do not bother getting user space stacktraces for kernel threads Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 3/8] tracing: Drop duplicated NO_CMDLINE_MAP check in saved_cmdlines_next() Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 4/8] tracing: Add __print_sym() to replace __print_symbolic() Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 5/8] net: dropreason: use new __print_sym() in tracing Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 6/8] net: drop_monitor: use drop_reason_lookup() Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 7/8] tracing: Dont use TRACE_BRANCH_BIT as a mask Steven Rostedt
2026-12-02 8:14 ` [for-next][PATCH 8/8] tracing: Use test_bit() in event_enable_count_probe() Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.