All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tracing: Have bpf and perf reuse the tracefs TRACE_EVENT macros
@ 2023-01-24 20:22 Steven Rostedt
  2023-01-24 20:22 ` [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros Steven Rostedt
  2023-01-24 20:22 ` [PATCH 2/2] bpf/tracing: " Steven Rostedt
  0 siblings, 2 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-01-24 20:22 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel
  Cc: Masami Hiramatsu, Andrew Morton, Linyu Yuan, Peter Zijlstra,
	Alexei Starovoitov, Daniel Borkmann, bpf

When reviewing Linyu Yuan patches[1] where the change was to move most
the macros from perf and bpf into stages, I realized that the macros
that makes up perf and bpf events are duplicated from the tracefs
macros that were moved into the stages directory. One reason to move
them into that directory was to remove duplicate code.

Remove the macros that are duplicated in the bpf and perf code and use
stage 6, which is the macros used to build the data needed to record
the TRACE_EVENT() TP_fast_assign() into the trace. This will mean they
will pick up bug fixes, as well as any enhacements that are added.

[1] https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/

Steven Rostedt (Google) (2):
      perf/tracing: Use stage6 of tracing to not duplicate macros
      bpf/tracing: Use stage6 of tracing to not duplicate macros

----
 include/trace/bpf_probe.h                    | 45 +--------------------------
 include/trace/perf.h                         | 46 +---------------------------
 include/trace/stages/stage6_event_callback.h |  3 ++
 3 files changed, 5 insertions(+), 89 deletions(-)

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

* [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros
  2023-01-24 20:22 [PATCH 0/2] tracing: Have bpf and perf reuse the tracefs TRACE_EVENT macros Steven Rostedt
@ 2023-01-24 20:22 ` Steven Rostedt
  2023-01-25  9:16   ` Peter Zijlstra
  2023-01-24 20:22 ` [PATCH 2/2] bpf/tracing: " Steven Rostedt
  1 sibling, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2023-01-24 20:22 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel
  Cc: Masami Hiramatsu, Andrew Morton, Linyu Yuan, Peter Zijlstra,
	Alexei Starovoitov, Daniel Borkmann, bpf, Frederic Weisbecker,
	Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The perf events are created by the same macro magic as tracefs trace
events are. But to hook into perf, it has its own code. It duplicates many
of the same macros as the tracefs macros and this is an issue because it
misses bug fixes as well as any new enhancements that come with the other
trace macros.

As the trace macros have been put into their own staging files, have perf
take advantage of this and use the tracefs stage 6 macros that the "fast
assign" portion of the trace event macro uses.

Link: https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Reported-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/perf.h                         | 46 +-------------------
 include/trace/stages/stage6_event_callback.h |  3 ++
 2 files changed, 4 insertions(+), 45 deletions(-)

diff --git a/include/trace/perf.h b/include/trace/perf.h
index 8f3bf1e17707..2c11181c82e0 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -4,51 +4,7 @@
 
 #ifdef CONFIG_PERF_EVENTS
 
-#undef __entry
-#define __entry entry
-
-#undef __get_dynamic_array
-#define __get_dynamic_array(field)	\
-		((void *)__entry + (__entry->__data_loc_##field & 0xffff))
-
-#undef __get_dynamic_array_len
-#define __get_dynamic_array_len(field)	\
-		((__entry->__data_loc_##field >> 16) & 0xffff)
-
-#undef __get_str
-#define __get_str(field) ((char *)__get_dynamic_array(field))
-
-#undef __get_bitmask
-#define __get_bitmask(field) (char *)__get_dynamic_array(field)
-
-#undef __get_cpumask
-#define __get_cpumask(field) (char *)__get_dynamic_array(field)
-
-#undef __get_sockaddr
-#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
-
-#undef __get_rel_dynamic_array
-#define __get_rel_dynamic_array(field)	\
-		((void *)__entry +					\
-		 offsetof(typeof(*__entry), __rel_loc_##field) +	\
-		 sizeof(__entry->__rel_loc_##field) +			\
-		 (__entry->__rel_loc_##field & 0xffff))
-
-#undef __get_rel_dynamic_array_len
-#define __get_rel_dynamic_array_len(field)	\
-		((__entry->__rel_loc_##field >> 16) & 0xffff)
-
-#undef __get_rel_str
-#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
-
-#undef __get_rel_bitmask
-#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
-
-#undef __get_rel_cpumask
-#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field)
-
-#undef __get_rel_sockaddr
-#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
+#include "stages/stage6_event_callback.h"
 
 #undef __perf_count
 #define __perf_count(c)	(__count = (c))
diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h
index 49c32394b53f..919b1a4da980 100644
--- a/include/trace/stages/stage6_event_callback.h
+++ b/include/trace/stages/stage6_event_callback.h
@@ -2,6 +2,9 @@
 
 /* Stage 6 definitions for creating trace events */
 
+/* Reuse some of the stage 3 macros */
+#include "stage3_trace_output.h"
+
 #undef __entry
 #define __entry entry
 
-- 
2.39.0



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

* [PATCH 2/2] bpf/tracing: Use stage6 of tracing to not duplicate macros
  2023-01-24 20:22 [PATCH 0/2] tracing: Have bpf and perf reuse the tracefs TRACE_EVENT macros Steven Rostedt
  2023-01-24 20:22 ` [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros Steven Rostedt
@ 2023-01-24 20:22 ` Steven Rostedt
  2023-01-24 21:11   ` Alexei Starovoitov
  1 sibling, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2023-01-24 20:22 UTC (permalink / raw)
  To: linux-kernel, linux-trace-kernel
  Cc: Masami Hiramatsu, Andrew Morton, Linyu Yuan, Peter Zijlstra,
	Alexei Starovoitov, Daniel Borkmann, bpf

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The bpf events are created by the same macro magic as tracefs trace
events are. But to hook into bpf, it has its own code. It duplicates many
of the same macros as the tracefs macros and this is an issue because it
misses bug fixes as well as any new enhancements that come with the other
trace macros.

As the trace macros have been put into their own staging files, have bpf
take advantage of this and use the tracefs stage 6 macros that the "fast
ssign" portion of the trace event macro uses.

Link: https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/

Cc: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Reported-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/bpf_probe.h | 45 +--------------------------------------
 1 file changed, 1 insertion(+), 44 deletions(-)

diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index 155c495b89ea..1f7fc1fc590c 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -4,50 +4,7 @@
 
 #ifdef CONFIG_BPF_EVENTS
 
-#undef __entry
-#define __entry entry
-
-#undef __get_dynamic_array
-#define __get_dynamic_array(field)	\
-		((void *)__entry + (__entry->__data_loc_##field & 0xffff))
-
-#undef __get_dynamic_array_len
-#define __get_dynamic_array_len(field)	\
-		((__entry->__data_loc_##field >> 16) & 0xffff)
-
-#undef __get_str
-#define __get_str(field) ((char *)__get_dynamic_array(field))
-
-#undef __get_bitmask
-#define __get_bitmask(field) (char *)__get_dynamic_array(field)
-
-#undef __get_cpumask
-#define __get_cpumask(field) (char *)__get_dynamic_array(field)
-
-#undef __get_sockaddr
-#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
-
-#undef __get_rel_dynamic_array
-#define __get_rel_dynamic_array(field)	\
-		((void *)(&__entry->__rel_loc_##field) +	\
-		 sizeof(__entry->__rel_loc_##field) +		\
-		 (__entry->__rel_loc_##field & 0xffff))
-
-#undef __get_rel_dynamic_array_len
-#define __get_rel_dynamic_array_len(field)	\
-		((__entry->__rel_loc_##field >> 16) & 0xffff)
-
-#undef __get_rel_str
-#define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
-
-#undef __get_rel_bitmask
-#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
-
-#undef __get_rel_cpumask
-#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field)
-
-#undef __get_rel_sockaddr
-#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
+#include "stages/stage6_event_callback.h"
 
 #undef __perf_count
 #define __perf_count(c)	(c)
-- 
2.39.0



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

* Re: [PATCH 2/2] bpf/tracing: Use stage6 of tracing to not duplicate macros
  2023-01-24 20:22 ` [PATCH 2/2] bpf/tracing: " Steven Rostedt
@ 2023-01-24 21:11   ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2023-01-24 21:11 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, linux-trace-kernel, Masami Hiramatsu, Andrew Morton,
	Linyu Yuan, Peter Zijlstra, Alexei Starovoitov, Daniel Borkmann,
	bpf

On Tue, Jan 24, 2023 at 12:25 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> The bpf events are created by the same macro magic as tracefs trace
> events are. But to hook into bpf, it has its own code. It duplicates many
> of the same macros as the tracefs macros and this is an issue because it
> misses bug fixes as well as any new enhancements that come with the other
> trace macros.
>
> As the trace macros have been put into their own staging files, have bpf
> take advantage of this and use the tracefs stage 6 macros that the "fast
> ssign" portion of the trace event macro uses.
>
> Link: https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/
>
> Cc: bpf@vger.kernel.org
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Reported-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Nice cleanup.
Acked-by: Alexei Starovoitov <ast@kernel.org>

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

* Re: [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros
  2023-01-24 20:22 ` [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros Steven Rostedt
@ 2023-01-25  9:16   ` Peter Zijlstra
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2023-01-25  9:16 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-trace-kernel, Masami Hiramatsu,
	Andrew Morton, Linyu Yuan, Alexei Starovoitov, Daniel Borkmann,
	bpf, Frederic Weisbecker, Arnaldo Carvalho de Melo, Ingo Molnar

On Tue, Jan 24, 2023 at 03:22:39PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> The perf events are created by the same macro magic as tracefs trace
> events are. But to hook into perf, it has its own code. It duplicates many
> of the same macros as the tracefs macros and this is an issue because it
> misses bug fixes as well as any new enhancements that come with the other
> trace macros.
> 
> As the trace macros have been put into their own staging files, have perf
> take advantage of this and use the tracefs stage 6 macros that the "fast
> assign" portion of the trace event macro uses.
> 
> Link: https://lore.kernel.org/lkml/1671181385-5719-1-git-send-email-quic_linyyuan@quicinc.com/
> 
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Ingo Molnar <mingo@elte.hu>
> Reported-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

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

end of thread, other threads:[~2023-01-25  9:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 20:22 [PATCH 0/2] tracing: Have bpf and perf reuse the tracefs TRACE_EVENT macros Steven Rostedt
2023-01-24 20:22 ` [PATCH 1/2] perf/tracing: Use stage6 of tracing to not duplicate macros Steven Rostedt
2023-01-25  9:16   ` Peter Zijlstra
2023-01-24 20:22 ` [PATCH 2/2] bpf/tracing: " Steven Rostedt
2023-01-24 21:11   ` Alexei Starovoitov

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.