Skip to content

Commit

Permalink
tracing: bpf: Hide bpf trace events when they are not used
Browse files Browse the repository at this point in the history
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) <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
rostedt authored and davem330 committed Oct 16, 2017
1 parent 0da4af0 commit 9185a61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/trace/events/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
3 changes: 3 additions & 0 deletions kernel/bpf/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,5 +1580,8 @@ int __weak skb_copy_bits(const struct sk_buff *skb, int offset, void *to,

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

0 comments on commit 9185a61

Please sign in to comment.