netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: bpf: Hide bpf trace events when they are not used
@ 2017-10-12 22:40 Steven Rostedt
  2017-10-13  1:14 ` Alexei Starovoitov
  2017-10-16 19:54 ` David Miller
  0 siblings, 2 replies; 9+ messages in thread
From: Steven Rostedt @ 2017-10-12 22:40 UTC (permalink / raw)
  To: LKML; +Cc: Alexei Starovoitov, Daniel Borkmann, David S. Miller, netdev

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

All the trace events defined in include/trace/events/bpf.h are only
used when CONFIG_BPF_SYSCALL is defined. But this file gets included by
include/linux/bpf_trace.h which is included by the networking code with
CREATE_TRACE_POINTS defined.

If a trace event is created but not used it still has data structures
and functions created for its use, even though nothing is using them.
To not waste space, do not define the BPF trace events in bpf.h unless
CONFIG_BPF_SYSCALL is defined.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Index: linux-trace.git/include/trace/events/bpf.h
===================================================================
--- linux-trace.git.orig/include/trace/events/bpf.h
+++ linux-trace.git/include/trace/events/bpf.h
@@ -4,6 +4,9 @@
 #if !defined(_TRACE_BPF_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_BPF_H
 
+/* These are only used within the BPF_SYSCALL code */
+#ifdef CONFIG_BPF_SYSCALL
+
 #include <linux/filter.h>
 #include <linux/bpf.h>
 #include <linux/fs.h>
@@ -345,7 +348,7 @@ TRACE_EVENT(bpf_map_next_key,
 		  __print_hex(__get_dynamic_array(nxt), __entry->key_len),
 		  __entry->key_trunc ? " ..." : "")
 );
-
+#endif /* CONFIG_BPF_SYSCALL */
 #endif /* _TRACE_BPF_H */
 
 #include <trace/define_trace.h>
Index: linux-trace.git/kernel/bpf/core.c
===================================================================
--- linux-trace.git.orig/kernel/bpf/core.c
+++ linux-trace.git/kernel/bpf/core.c
@@ -1498,5 +1498,8 @@ int __weak skb_copy_bits(const struct sk
 
 EXPORT_TRACEPOINT_SYMBOL_GPL(xdp_exception);
 
+/* These are only used within the BPF_SYSCALL code */
+#ifdef CONFIG_BPF_SYSCALL
 EXPORT_TRACEPOINT_SYMBOL_GPL(bpf_prog_get_type);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bpf_prog_put_rcu);
+#endif

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

end of thread, other threads:[~2017-10-16 20:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12 22:40 [PATCH] tracing: bpf: Hide bpf trace events when they are not used Steven Rostedt
2017-10-13  1:14 ` Alexei Starovoitov
2017-10-13  1:35   ` Steven Rostedt
2017-10-13  1:38     ` Alexei Starovoitov
2017-10-13  1:49       ` Steven Rostedt
2017-10-16 19:54 ` David Miller
2017-10-16 20:01   ` Steven Rostedt
2017-10-16 20:11     ` David Miller
2017-10-16 20:21       ` 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).