netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
@ 2025-04-18 15:01 Steven Rostedt
  2025-04-21 12:44 ` Jiri Olsa
  2025-04-23 18:21 ` Andrii Nakryiko
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2025-04-18 15:01 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Mathieu Desnoyers, Masami Hiramatsu, Peter Zijlstra, David Ahern,
	Juri Lelli, Breno Leitao, netdev, Alexei Starovoitov,
	Andrii Nakryiko, bpf, Gabriele Monaco

From: Steven Rostedt <rostedt@goodmis.org>

Most tracepoints in the kernel are created with TRACE_EVENT(). The
TRACE_EVENT() macro (and DECLARE_EVENT_CLASS() and DEFINE_EVENT() where in
reality, TRACE_EVENT() is just a helper macro that calls those other two
macros), will create not only a tracepoint (the function trace_<event>()
used in the kernel), it also exposes the tracepoint to user space along
with defining what fields will be saved by that tracepoint.

There are a few places that tracepoints are created in the kernel that are
not exposed to userspace via tracefs. They can only be accessed from code
within the kernel. These tracepoints are created with DEFINE_TRACE()

Most of these tracepoints end with "_tp". This is useful as when the
developer sees that, they know that the tracepoint is for in-kernel only
and is not exposed to user space.

Instead of making this only a process to add "_tp", enforce it by making
the DECLARE_TRACE() append the "_tp" suffix to the tracepoint. This
requires adding DECLARE_TRACE_EVENT() macros for the TRACE_EVENT() macro
to use that keeps the original name.

Link: https://lore.kernel.org/all/20250418083351.20a60e64@gandalf.local.home/

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/linux/tracepoint.h   | 38 ++++++++++++++++++++++++------------
 include/trace/bpf_probe.h    |  4 ++--
 include/trace/define_trace.h | 17 +++++++++++++++-
 include/trace/events/sched.h | 30 ++++++++++++++--------------
 include/trace/events/tcp.h   |  2 +-
 5 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a351763e6965..826ce3f8e1f8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -464,16 +464,30 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 #endif
 
 #define DECLARE_TRACE(name, proto, args)				\
-	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
+	__DECLARE_TRACE(name##_tp, PARAMS(proto), PARAMS(args),		\
 			cpu_online(raw_smp_processor_id()),		\
 			PARAMS(void *__data, proto))
 
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)		\
-	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
+	__DECLARE_TRACE(name##_tp, PARAMS(proto), PARAMS(args),		\
 			cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
 			PARAMS(void *__data, proto))
 
 #define DECLARE_TRACE_SYSCALL(name, proto, args)			\
+	__DECLARE_TRACE_SYSCALL(name##_tp, PARAMS(proto), PARAMS(args),	\
+				PARAMS(void *__data, proto))
+
+#define DECLARE_TRACE_EVENT(name, proto, args)				\
+	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
+			cpu_online(raw_smp_processor_id()),		\
+			PARAMS(void *__data, proto))
+
+#define DECLARE_TRACE_EVENT_CONDITION(name, proto, args, cond)		\
+	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
+			cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
+			PARAMS(void *__data, proto))
+
+#define DECLARE_TRACE_EVENT_SYSCALL(name, proto, args)			\
 	__DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args),	\
 				PARAMS(void *__data, proto))
 
@@ -591,32 +605,32 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 
 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
 #define DEFINE_EVENT(template, name, proto, args)		\
-	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
 #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
-	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
-	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
 #define DEFINE_EVENT_CONDITION(template, name, proto,		\
 			       args, cond)			\
-	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
+	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
 				PARAMS(args), PARAMS(cond))
 
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
-	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
 #define TRACE_EVENT_FN(name, proto, args, struct,		\
 		assign, print, reg, unreg)			\
-	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
-#define TRACE_EVENT_FN_COND(name, proto, args, cond, struct,		\
+	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN_COND(name, proto, args, cond, struct,	\
 		assign, print, reg, unreg)			\
-	DECLARE_TRACE_CONDITION(name, PARAMS(proto),	\
+	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
 			PARAMS(args), PARAMS(cond))
 #define TRACE_EVENT_CONDITION(name, proto, args, cond,		\
 			      struct, assign, print)		\
-	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
+	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
 				PARAMS(args), PARAMS(cond))
 #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign,	\
 			    print, reg, unreg)			\
-	DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args))
+	DECLARE_TRACE_EVENT_SYSCALL(name, PARAMS(proto), PARAMS(args))
 
 #define TRACE_EVENT_FLAGS(event, flag)
 
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index 183fa2aa2935..fbfe83b939ac 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -119,8 +119,8 @@ static inline void bpf_test_buffer_##call(void)				\
 
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(call, proto, args)				\
-	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
-	__DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0)
+	__BPF_DECLARE_TRACE(call##_tp, PARAMS(proto), PARAMS(args))		\
+	__DEFINE_EVENT(call##_tp, call##_tp, PARAMS(proto), PARAMS(args), 0)
 
 #undef DECLARE_TRACE_WRITABLE
 #define DECLARE_TRACE_WRITABLE(call, proto, args, size) \
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index ed52d0506c69..b2ba5a80583f 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -74,10 +74,18 @@
 
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)	\
-	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+	DEFINE_TRACE(name##_tp, PARAMS(proto), PARAMS(args))
 
 #undef DECLARE_TRACE_CONDITION
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)	\
+	DEFINE_TRACE(name##_tp, PARAMS(proto), PARAMS(args))
+
+#undef DECLARE_TRACE_EVENT
+#define DECLARE_TRACE_EVENT(name, proto, args)	\
+	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+
+#undef DECLARE_TRACE_EVENT_CONDITION
+#define DECLARE_TRACE_EVENT_CONDITION(name, proto, args, cond)	\
 	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
 
 /* If requested, create helpers for calling these tracepoints from Rust. */
@@ -115,6 +123,11 @@
 #undef DECLARE_TRACE_CONDITION
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)
 
+#undef DECLARE_TRACE_EVENT
+#define DECLARE_TRACE_EVENT(name, proto, args)
+#undef DECLARE_TRACE_EVENT_CONDITION
+#define DECLARE_TRACE_EVENT_CONDITION(name, proto, args, cond)
+
 #ifdef TRACEPOINTS_ENABLED
 #include <trace/trace_events.h>
 #include <trace/perf.h>
@@ -136,6 +149,8 @@
 #undef TRACE_HEADER_MULTI_READ
 #undef DECLARE_TRACE
 #undef DECLARE_TRACE_CONDITION
+#undef DECLARE_TRACE_EVENT
+#undef DECLARE_TRACE_EVENT_CONDITION
 
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 8994e97d86c1..152fc8b37aa5 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -773,64 +773,64 @@ TRACE_EVENT(sched_wake_idle_without_ipi,
  *
  * Postfixed with _tp to make them easily identifiable in the code.
  */
-DECLARE_TRACE(pelt_cfs_tp,
+DECLARE_TRACE(pelt_cfs,
 	TP_PROTO(struct cfs_rq *cfs_rq),
 	TP_ARGS(cfs_rq));
 
-DECLARE_TRACE(pelt_rt_tp,
+DECLARE_TRACE(pelt_rt,
 	TP_PROTO(struct rq *rq),
 	TP_ARGS(rq));
 
-DECLARE_TRACE(pelt_dl_tp,
+DECLARE_TRACE(pelt_dl,
 	TP_PROTO(struct rq *rq),
 	TP_ARGS(rq));
 
-DECLARE_TRACE(pelt_hw_tp,
+DECLARE_TRACE(pelt_hw,
 	TP_PROTO(struct rq *rq),
 	TP_ARGS(rq));
 
-DECLARE_TRACE(pelt_irq_tp,
+DECLARE_TRACE(pelt_irq,
 	TP_PROTO(struct rq *rq),
 	TP_ARGS(rq));
 
-DECLARE_TRACE(pelt_se_tp,
+DECLARE_TRACE(pelt_se,
 	TP_PROTO(struct sched_entity *se),
 	TP_ARGS(se));
 
-DECLARE_TRACE(sched_cpu_capacity_tp,
+DECLARE_TRACE(sched_cpu_capacity,
 	TP_PROTO(struct rq *rq),
 	TP_ARGS(rq));
 
-DECLARE_TRACE(sched_overutilized_tp,
+DECLARE_TRACE(sched_overutilized,
 	TP_PROTO(struct root_domain *rd, bool overutilized),
 	TP_ARGS(rd, overutilized));
 
-DECLARE_TRACE(sched_util_est_cfs_tp,
+DECLARE_TRACE(sched_util_est_cfs,
 	TP_PROTO(struct cfs_rq *cfs_rq),
 	TP_ARGS(cfs_rq));
 
-DECLARE_TRACE(sched_util_est_se_tp,
+DECLARE_TRACE(sched_util_est_se,
 	TP_PROTO(struct sched_entity *se),
 	TP_ARGS(se));
 
-DECLARE_TRACE(sched_update_nr_running_tp,
+DECLARE_TRACE(sched_update_nr_running,
 	TP_PROTO(struct rq *rq, int change),
 	TP_ARGS(rq, change));
 
-DECLARE_TRACE(sched_compute_energy_tp,
+DECLARE_TRACE(sched_compute_energy,
 	TP_PROTO(struct task_struct *p, int dst_cpu, unsigned long energy,
 		 unsigned long max_util, unsigned long busy_time),
 	TP_ARGS(p, dst_cpu, energy, max_util, busy_time));
 
-DECLARE_TRACE(sched_entry_tp,
+DECLARE_TRACE(sched_entry,
 	TP_PROTO(bool preempt, unsigned long ip),
 	TP_ARGS(preempt, ip));
 
-DECLARE_TRACE(sched_exit_tp,
+DECLARE_TRACE(sched_exit,
 	TP_PROTO(bool is_switch, unsigned long ip),
 	TP_ARGS(is_switch, ip));
 
-DECLARE_TRACE_CONDITION(sched_set_state_tp,
+DECLARE_TRACE_CONDITION(sched_set_state,
 	TP_PROTO(struct task_struct *tsk, int state),
 	TP_ARGS(tsk, state),
 	TP_CONDITION(!!(tsk->__state) != !!state));
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 1a40c41ff8c3..4f9fa1b5b89b 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -259,7 +259,7 @@ TRACE_EVENT(tcp_retransmit_synack,
 		  __entry->saddr_v6, __entry->daddr_v6)
 );
 
-DECLARE_TRACE(tcp_cwnd_reduction_tp,
+DECLARE_TRACE(tcp_cwnd_reduction,
 	TP_PROTO(const struct sock *sk, int newly_acked_sacked,
 		 int newly_lost, int flag),
 	TP_ARGS(sk, newly_acked_sacked, newly_lost, flag)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-18 15:01 [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix Steven Rostedt
@ 2025-04-21 12:44 ` Jiri Olsa
  2025-04-21 13:58   ` Steven Rostedt
  2025-04-23 18:21 ` Andrii Nakryiko
  1 sibling, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2025-04-21 12:44 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, Andrii Nakryiko, bpf, Gabriele Monaco

On Fri, Apr 18, 2025 at 11:01:04AM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> Most tracepoints in the kernel are created with TRACE_EVENT(). The
> TRACE_EVENT() macro (and DECLARE_EVENT_CLASS() and DEFINE_EVENT() where in
> reality, TRACE_EVENT() is just a helper macro that calls those other two
> macros), will create not only a tracepoint (the function trace_<event>()
> used in the kernel), it also exposes the tracepoint to user space along
> with defining what fields will be saved by that tracepoint.
> 
> There are a few places that tracepoints are created in the kernel that are
> not exposed to userspace via tracefs. They can only be accessed from code
> within the kernel. These tracepoints are created with DEFINE_TRACE()
> 
> Most of these tracepoints end with "_tp". This is useful as when the
> developer sees that, they know that the tracepoint is for in-kernel only
> and is not exposed to user space.
> 
> Instead of making this only a process to add "_tp", enforce it by making
> the DECLARE_TRACE() append the "_tp" suffix to the tracepoint. This
> requires adding DECLARE_TRACE_EVENT() macros for the TRACE_EVENT() macro
> to use that keeps the original name.
> 
> Link: https://lore.kernel.org/all/20250418083351.20a60e64@gandalf.local.home/
> 
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  include/linux/tracepoint.h   | 38 ++++++++++++++++++++++++------------
>  include/trace/bpf_probe.h    |  4 ++--
>  include/trace/define_trace.h | 17 +++++++++++++++-
>  include/trace/events/sched.h | 30 ++++++++++++++--------------
>  include/trace/events/tcp.h   |  2 +-
>  5 files changed, 60 insertions(+), 31 deletions(-)
> 
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index a351763e6965..826ce3f8e1f8 100644
> --- a/include/linux/tracepoint.h
> +++ b/include/linux/tracepoint.h
> @@ -464,16 +464,30 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  #endif
>  
>  #define DECLARE_TRACE(name, proto, args)				\
> -	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
> +	__DECLARE_TRACE(name##_tp, PARAMS(proto), PARAMS(args),		\
>  			cpu_online(raw_smp_processor_id()),		\
>  			PARAMS(void *__data, proto))
>  
>  #define DECLARE_TRACE_CONDITION(name, proto, args, cond)		\
> -	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
> +	__DECLARE_TRACE(name##_tp, PARAMS(proto), PARAMS(args),		\
>  			cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
>  			PARAMS(void *__data, proto))
>  
>  #define DECLARE_TRACE_SYSCALL(name, proto, args)			\
> +	__DECLARE_TRACE_SYSCALL(name##_tp, PARAMS(proto), PARAMS(args),	\
> +				PARAMS(void *__data, proto))
> +
> +#define DECLARE_TRACE_EVENT(name, proto, args)				\
> +	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
> +			cpu_online(raw_smp_processor_id()),		\
> +			PARAMS(void *__data, proto))
> +
> +#define DECLARE_TRACE_EVENT_CONDITION(name, proto, args, cond)		\
> +	__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),		\
> +			cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
> +			PARAMS(void *__data, proto))
> +
> +#define DECLARE_TRACE_EVENT_SYSCALL(name, proto, args)			\
>  	__DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args),	\
>  				PARAMS(void *__data, proto))
>  
> @@ -591,32 +605,32 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  
>  #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
>  #define DEFINE_EVENT(template, name, proto, args)		\
> -	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> +	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
>  #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
> -	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> +	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
>  #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
> -	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> +	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
>  #define DEFINE_EVENT_CONDITION(template, name, proto,		\
>  			       args, cond)			\
> -	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
> +	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
>  				PARAMS(args), PARAMS(cond))
>  
>  #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
> -	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> +	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
>  #define TRACE_EVENT_FN(name, proto, args, struct,		\
>  		assign, print, reg, unreg)			\
> -	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
> -#define TRACE_EVENT_FN_COND(name, proto, args, cond, struct,		\
> +	DECLARE_TRACE_EVENT(name, PARAMS(proto), PARAMS(args))
> +#define TRACE_EVENT_FN_COND(name, proto, args, cond, struct,	\
>  		assign, print, reg, unreg)			\
> -	DECLARE_TRACE_CONDITION(name, PARAMS(proto),	\
> +	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
>  			PARAMS(args), PARAMS(cond))
>  #define TRACE_EVENT_CONDITION(name, proto, args, cond,		\
>  			      struct, assign, print)		\
> -	DECLARE_TRACE_CONDITION(name, PARAMS(proto),		\
> +	DECLARE_TRACE_EVENT_CONDITION(name, PARAMS(proto),	\
>  				PARAMS(args), PARAMS(cond))
>  #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign,	\
>  			    print, reg, unreg)			\
> -	DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args))
> +	DECLARE_TRACE_EVENT_SYSCALL(name, PARAMS(proto), PARAMS(args))
>  
>  #define TRACE_EVENT_FLAGS(event, flag)
>  
> diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
> index 183fa2aa2935..fbfe83b939ac 100644
> --- a/include/trace/bpf_probe.h
> +++ b/include/trace/bpf_probe.h
> @@ -119,8 +119,8 @@ static inline void bpf_test_buffer_##call(void)				\
>  
>  #undef DECLARE_TRACE
>  #define DECLARE_TRACE(call, proto, args)				\
> -	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
> -	__DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0)
> +	__BPF_DECLARE_TRACE(call##_tp, PARAMS(proto), PARAMS(args))		\
> +	__DEFINE_EVENT(call##_tp, call##_tp, PARAMS(proto), PARAMS(args), 0)
>  
>  #undef DECLARE_TRACE_WRITABLE
>  #define DECLARE_TRACE_WRITABLE(call, proto, args, size) \

hi,
do we need the change also for DECLARE_TRACE_WRITABLE?
I needed change below for bpf selftest kmod

jirka


---
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index fbfe83b939ac..9391d54d3f12 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -125,8 +125,8 @@ static inline void bpf_test_buffer_##call(void)				\
 #undef DECLARE_TRACE_WRITABLE
 #define DECLARE_TRACE_WRITABLE(call, proto, args, size) \
 	__CHECK_WRITABLE_BUF_SIZE(call, PARAMS(proto), PARAMS(args), size) \
-	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \
-	__DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), size)
+	__BPF_DECLARE_TRACE(call##_tp, PARAMS(proto), PARAMS(args)) \
+	__DEFINE_EVENT(call##_tp, call##_tp, PARAMS(proto), PARAMS(args), size)
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
index aeef86b3da74..2bac14ef507f 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
@@ -42,7 +42,7 @@ DECLARE_TRACE(bpf_testmod_test_nullable_bare,
 
 struct sk_buff;
 
-DECLARE_TRACE(bpf_testmod_test_raw_tp_null,
+DECLARE_TRACE(bpf_testmod_test_raw_null,
 	TP_PROTO(struct sk_buff *skb),
 	TP_ARGS(skb)
 );
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
index f38eaf0d35ef..dd9b806d255e 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
@@ -413,7 +413,7 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
 
 	(void)bpf_testmod_test_arg_ptr_to_struct(&struct_arg1_2);
 
-	(void)trace_bpf_testmod_test_raw_tp_null(NULL);
+	(void)trace_bpf_testmod_test_raw_null_tp(NULL);
 
 	bpf_testmod_test_struct_ops3();
 
@@ -431,14 +431,14 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
 	if (bpf_testmod_loop_test(101) > 100)
 		trace_bpf_testmod_test_read(current, &ctx);
 
-	trace_bpf_testmod_test_nullable_bare(NULL);
+	trace_bpf_testmod_test_nullable_bare_tp(NULL);
 
 	/* Magic number to enable writable tp */
 	if (len == 64) {
 		struct bpf_testmod_test_writable_ctx writable = {
 			.val = 1024,
 		};
-		trace_bpf_testmod_test_writable_bare(&writable);
+		trace_bpf_testmod_test_writable_bare_tp(&writable);
 		if (writable.early_ret)
 			return snprintf(buf, len, "%d\n", writable.val);
 	}
@@ -470,7 +470,7 @@ bpf_testmod_test_write(struct file *file, struct kobject *kobj,
 		.len = len,
 	};
 
-	trace_bpf_testmod_test_write_bare(current, &ctx);
+	trace_bpf_testmod_test_write_bare_tp(current, &ctx);
 
 	return -EIO; /* always fail */
 }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-21 12:44 ` Jiri Olsa
@ 2025-04-21 13:58   ` Steven Rostedt
  2025-04-21 14:53     ` Mathieu Desnoyers
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2025-04-21 13:58 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, Andrii Nakryiko, bpf, Gabriele Monaco

On Mon, 21 Apr 2025 14:44:21 +0200
Jiri Olsa <olsajiri@gmail.com> wrote:

> hi,
> do we need the change also for DECLARE_TRACE_WRITABLE?

Probably ;-)

> I needed change below for bpf selftest kmod

Thanks, I'll fold this in.

I'll make a more formal patch if nobody has any objections.

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-21 13:58   ` Steven Rostedt
@ 2025-04-21 14:53     ` Mathieu Desnoyers
  0 siblings, 0 replies; 8+ messages in thread
From: Mathieu Desnoyers @ 2025-04-21 14:53 UTC (permalink / raw)
  To: Steven Rostedt, Jiri Olsa
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Peter Zijlstra,
	David Ahern, Juri Lelli, Breno Leitao, netdev, Alexei Starovoitov,
	Andrii Nakryiko, bpf, Gabriele Monaco

On 2025-04-21 09:58, Steven Rostedt wrote:
> On Mon, 21 Apr 2025 14:44:21 +0200
> Jiri Olsa <olsajiri@gmail.com> wrote:
> 
>> hi,
>> do we need the change also for DECLARE_TRACE_WRITABLE?
> 
> Probably ;-)
> 
>> I needed change below for bpf selftest kmod
> 
> Thanks, I'll fold this in.
> 
> I'll make a more formal patch if nobody has any objections.

No objection from me:

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Thanks!

Mathieu

> 
> -- Steve


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-18 15:01 [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix Steven Rostedt
  2025-04-21 12:44 ` Jiri Olsa
@ 2025-04-23 18:21 ` Andrii Nakryiko
  2025-04-23 18:53   ` Steven Rostedt
  1 sibling, 1 reply; 8+ messages in thread
From: Andrii Nakryiko @ 2025-04-23 18:21 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, bpf, Gabriele Monaco

On Fri, Apr 18, 2025 at 7:59 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: Steven Rostedt <rostedt@goodmis.org>
>
> Most tracepoints in the kernel are created with TRACE_EVENT(). The
> TRACE_EVENT() macro (and DECLARE_EVENT_CLASS() and DEFINE_EVENT() where in
> reality, TRACE_EVENT() is just a helper macro that calls those other two
> macros), will create not only a tracepoint (the function trace_<event>()
> used in the kernel), it also exposes the tracepoint to user space along
> with defining what fields will be saved by that tracepoint.
>
> There are a few places that tracepoints are created in the kernel that are
> not exposed to userspace via tracefs. They can only be accessed from code
> within the kernel. These tracepoints are created with DEFINE_TRACE()

The part about accessing only from code within the kernel isn't true.
Can we please drop that? BPF program can be attached to these bare
tracepoints just fine without tracefs (so-called BPF raw tracepoint
program types).

But I don't have an objection to the change itself, given all of them
currently do have _tp suffix except a few that we have in BPF
selftests's module, just as Jiri mentioned.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>
> Most of these tracepoints end with "_tp". This is useful as when the
> developer sees that, they know that the tracepoint is for in-kernel only
> and is not exposed to user space.
>
> Instead of making this only a process to add "_tp", enforce it by making
> the DECLARE_TRACE() append the "_tp" suffix to the tracepoint. This
> requires adding DECLARE_TRACE_EVENT() macros for the TRACE_EVENT() macro
> to use that keeps the original name.
>
> Link: https://lore.kernel.org/all/20250418083351.20a60e64@gandalf.local.home/
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  include/linux/tracepoint.h   | 38 ++++++++++++++++++++++++------------
>  include/trace/bpf_probe.h    |  4 ++--
>  include/trace/define_trace.h | 17 +++++++++++++++-
>  include/trace/events/sched.h | 30 ++++++++++++++--------------
>  include/trace/events/tcp.h   |  2 +-
>  5 files changed, 60 insertions(+), 31 deletions(-)
>

[...]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-23 18:21 ` Andrii Nakryiko
@ 2025-04-23 18:53   ` Steven Rostedt
  2025-04-23 21:21     ` Andrii Nakryiko
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2025-04-23 18:53 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, bpf, Gabriele Monaco

On Wed, 23 Apr 2025 11:21:25 -0700
Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:

> The part about accessing only from code within the kernel isn't true.
> Can we please drop that? BPF program can be attached to these bare
> tracepoints just fine without tracefs (so-called BPF raw tracepoint
> program types).

Is it possible to see a list of these tracepoints from user space? If not,
then it's only available via the kernel. Sure BPF and even trace probes can
attach to them. Just like attaching to functions. The point is, they are
not exposed directly to user space. User space only knows about it if the
user has access to the kernel.

Unless BPF does expose what's avaliable, does it?

> 
> But I don't have an objection to the change itself, given all of them
> currently do have _tp suffix except a few that we have in BPF
> selftests's module, just as Jiri mentioned.
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>

Thanks,

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-23 18:53   ` Steven Rostedt
@ 2025-04-23 21:21     ` Andrii Nakryiko
  2025-04-23 21:27       ` Steven Rostedt
  0 siblings, 1 reply; 8+ messages in thread
From: Andrii Nakryiko @ 2025-04-23 21:21 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, bpf, Gabriele Monaco

On Wed, Apr 23, 2025 at 11:51 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 23 Apr 2025 11:21:25 -0700
> Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
>
> > The part about accessing only from code within the kernel isn't true.
> > Can we please drop that? BPF program can be attached to these bare
> > tracepoints just fine without tracefs (so-called BPF raw tracepoint
> > program types).
>
> Is it possible to see a list of these tracepoints from user space? If not,
> then it's only available via the kernel. Sure BPF and even trace probes can
> attach to them. Just like attaching to functions. The point is, they are
> not exposed directly to user space. User space only knows about it if the
> user has access to the kernel.
>
> Unless BPF does expose what's avaliable, does it?
>

BPF by itself doesn't have any API to list tracepoints, so in that
sense, no, BPF doesn't expose *the list* of those tracepoints. But the
same can be said about kprobes or normal tracepoints. But it is
allowed to attempt to attach to those tracepoints by just specifying
their name as a string.

I guess I'm confused about what "accessing only from code within the
kernel" means. In my mind BPF isn't really "code within the kernel",
but we are getting into the philosophical area now :) I just wanted to
point out that this is consumable/attachable with BPF just like any
other tracepoint, so it's not just kernel/module code that can attach
to them.

> >
> > But I don't have an objection to the change itself, given all of them
> > currently do have _tp suffix except a few that we have in BPF
> > selftests's module, just as Jiri mentioned.
> >
> > Acked-by: Andrii Nakryiko <andrii@kernel.org>
>
> Thanks,
>
> -- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix
  2025-04-23 21:21     ` Andrii Nakryiko
@ 2025-04-23 21:27       ` Steven Rostedt
  0 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2025-04-23 21:27 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, Masami Hiramatsu,
	Peter Zijlstra, David Ahern, Juri Lelli, Breno Leitao, netdev,
	Alexei Starovoitov, bpf, Gabriele Monaco

On Wed, 23 Apr 2025 14:21:24 -0700
Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:

> BPF by itself doesn't have any API to list tracepoints, so in that
> sense, no, BPF doesn't expose *the list* of those tracepoints. But the
> same can be said about kprobes or normal tracepoints. But it is
> allowed to attempt to attach to those tracepoints by just specifying
> their name as a string.
> 
> I guess I'm confused about what "accessing only from code within the
> kernel" means. In my mind BPF isn't really "code within the kernel",
> but we are getting into the philosophical area now :) I just wanted to
> point out that this is consumable/attachable with BPF just like any
> other tracepoint, so it's not just kernel/module code that can attach
> to them.

To continue the philosophical debate ;-) I'll argue that a BPF program runs
inside the kernel just like a module would. Hence, a BPF program is in
kernel space. In fact, from what I understand, that's the entire point of
BPF. To run in kernel space!

-- Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-04-23 21:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-18 15:01 [RFC][PATCH] tracepoint: Have tracepoints created with DECLARE_TRACE() have _tp suffix Steven Rostedt
2025-04-21 12:44 ` Jiri Olsa
2025-04-21 13:58   ` Steven Rostedt
2025-04-21 14:53     ` Mathieu Desnoyers
2025-04-23 18:21 ` Andrii Nakryiko
2025-04-23 18:53   ` Steven Rostedt
2025-04-23 21:21     ` Andrii Nakryiko
2025-04-23 21:27       ` Steven Rostedt

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).