Skip to content

Commit

Permalink
perf test bpf: Hook on epoll_pwait()
Browse files Browse the repository at this point in the history
The 'perf test bpf' was hooking a eBPF program on the SyS_epoll_wait()
kernel function, that was what the epoll_wait() glibc function ended up
calling, but since at least glibc 2.26, the one that comes with, for
instance, Fedora 27, glibc ends up calling SyS_epoll_pwait() when
epoll_wait() is used, causing this 'perf test' entry to fail.

So switch to using epoll_pwait() and hook the eBPF program to the
SyS_epoll_pwait() kernel function to make it work on a wider range of
glibc and kernel versions.

Tested-by: Wang Nan <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Jan 8, 2018
1 parent 13cb2d0 commit e0337f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tools/perf/tests/bpf-script-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ struct bpf_map_def SEC("maps") flip_table = {
.max_entries = 1,
};

SEC("func=SyS_epoll_wait")
int bpf_func__SyS_epoll_wait(void *ctx)
SEC("func=SyS_epoll_pwait")
int bpf_func__SyS_epoll_pwait(void *ctx)
{
int ind =0;
int *flag = bpf_map_lookup_elem(&flip_table, &ind);
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/tests/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

#ifdef HAVE_LIBBPF_SUPPORT

static int epoll_wait_loop(void)
static int epoll_pwait_loop(void)
{
int i;

/* Should fail NR_ITERS times */
for (i = 0; i < NR_ITERS; i++)
epoll_wait(-(i + 1), NULL, 0, 0);
epoll_pwait(-(i + 1), NULL, 0, 0, NULL);
return 0;
}

Expand Down Expand Up @@ -68,7 +68,7 @@ static struct {
.name = "[basic_bpf_test]",
.msg_compile_fail = "fix 'perf test LLVM' first",
.msg_load_fail = "load bpf object failed",
.target_func = &epoll_wait_loop,
.target_func = &epoll_pwait_loop,
.expect_result = (NR_ITERS + 1) / 2,
},
{
Expand All @@ -77,7 +77,7 @@ static struct {
.name = "[bpf_pinning]",
.msg_compile_fail = "fix kbuild first",
.msg_load_fail = "check your vmlinux setting?",
.target_func = &epoll_wait_loop,
.target_func = &epoll_pwait_loop,
.expect_result = (NR_ITERS + 1) / 2,
.pin = true,
},
Expand Down

0 comments on commit e0337f4

Please sign in to comment.