Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Make usage of test_attr__* optional for perf-sys.h

For users of perf-sys.h outside perf, e.g. samples/bpf/bpf_load.c, it's
convenient not to depend on test_attr__*.

After commit 91854f9a077e ("perf tools: Move everything related to
sys_perf_event_open() to perf-sys.h"), all users of perf-sys.h will
depend on test_attr__enabled and test_attr__open.

This commit enables a user to define HAVE_ATTR_TEST to zero in order
to omit the test dependency.

Fixes: 91854f9a077e ("perf tools: Move everything related to sys_perf_event_open() to perf-sys.h")
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: http://lore.kernel.org/bpf/20191001113307.27796-2-bjorn.topel@gmail.com

authored by

Björn Töpel and committed by
Daniel Borkmann
6bd7cf66 7541c87c

+4 -2
+4 -2
tools/perf/perf-sys.h
··· 15 15 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, 16 16 int fd, int group_fd, unsigned long flags); 17 17 18 - #define HAVE_ATTR_TEST 18 + #ifndef HAVE_ATTR_TEST 19 + #define HAVE_ATTR_TEST 1 20 + #endif 19 21 20 22 static inline int 21 23 sys_perf_event_open(struct perf_event_attr *attr, ··· 29 27 fd = syscall(__NR_perf_event_open, attr, pid, cpu, 30 28 group_fd, flags); 31 29 32 - #ifdef HAVE_ATTR_TEST 30 + #if HAVE_ATTR_TEST 33 31 if (unlikely(test_attr__enabled)) 34 32 test_attr__open(attr, pid, cpu, fd, group_fd, flags); 35 33 #endif