forked from Minki/linux
06f84d1989
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 commit91854f9a07
("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:91854f9a07
("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: Daniel Borkmann <daniel@iogearbox.net> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: bpf@vger.kernel.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20191001113307.27796-2-bjorn.topel@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
40 lines
856 B
C
40 lines
856 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _PERF_SYS_H
|
|
#define _PERF_SYS_H
|
|
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/syscall.h>
|
|
#include <linux/compiler.h>
|
|
|
|
struct perf_event_attr;
|
|
|
|
extern bool test_attr__enabled;
|
|
void test_attr__ready(void);
|
|
void test_attr__init(void);
|
|
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
|
|
int fd, int group_fd, unsigned long flags);
|
|
|
|
#ifndef HAVE_ATTR_TEST
|
|
#define HAVE_ATTR_TEST 1
|
|
#endif
|
|
|
|
static inline int
|
|
sys_perf_event_open(struct perf_event_attr *attr,
|
|
pid_t pid, int cpu, int group_fd,
|
|
unsigned long flags)
|
|
{
|
|
int fd;
|
|
|
|
fd = syscall(__NR_perf_event_open, attr, pid, cpu,
|
|
group_fd, flags);
|
|
|
|
#if HAVE_ATTR_TEST
|
|
if (unlikely(test_attr__enabled))
|
|
test_attr__open(attr, pid, cpu, fd, group_fd, flags);
|
|
#endif
|
|
return fd;
|
|
}
|
|
|
|
#endif /* _PERF_SYS_H */
|