selftests/bpf: fix perf_buffer on s390

perf_buffer test fails for exactly the same reason test_attach_probe
used to fail: different nanosleep syscall kprobe name.

Reuse the test_attach_probe fix.

Fixes: ee5cf82ce0 ("selftests/bpf: test perf buffer API")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Ilya Leoshkevich 2019-07-16 14:58:27 +02:00 committed by Alexei Starovoitov
parent 9d1f62a6dc
commit 1cb59a6074
3 changed files with 11 additions and 17 deletions

View File

@ -21,14 +21,6 @@ ssize_t get_base_addr() {
return -EINVAL; return -EINVAL;
} }
#ifdef __x86_64__
#define SYS_KPROBE_NAME "__x64_sys_nanosleep"
#elif defined(__s390x__)
#define SYS_KPROBE_NAME "__s390x_sys_nanosleep"
#else
#define SYS_KPROBE_NAME "sys_nanosleep"
#endif
void test_attach_probe(void) void test_attach_probe(void)
{ {
const char *kprobe_name = "kprobe/sys_nanosleep"; const char *kprobe_name = "kprobe/sys_nanosleep";
@ -86,7 +78,7 @@ void test_attach_probe(void)
kprobe_link = bpf_program__attach_kprobe(kprobe_prog, kprobe_link = bpf_program__attach_kprobe(kprobe_prog,
false /* retprobe */, false /* retprobe */,
SYS_KPROBE_NAME); SYS_NANOSLEEP_KPROBE_NAME);
if (CHECK(IS_ERR(kprobe_link), "attach_kprobe", if (CHECK(IS_ERR(kprobe_link), "attach_kprobe",
"err %ld\n", PTR_ERR(kprobe_link))) { "err %ld\n", PTR_ERR(kprobe_link))) {
kprobe_link = NULL; kprobe_link = NULL;
@ -94,7 +86,7 @@ void test_attach_probe(void)
} }
kretprobe_link = bpf_program__attach_kprobe(kretprobe_prog, kretprobe_link = bpf_program__attach_kprobe(kretprobe_prog,
true /* retprobe */, true /* retprobe */,
SYS_KPROBE_NAME); SYS_NANOSLEEP_KPROBE_NAME);
if (CHECK(IS_ERR(kretprobe_link), "attach_kretprobe", if (CHECK(IS_ERR(kretprobe_link), "attach_kretprobe",
"err %ld\n", PTR_ERR(kretprobe_link))) { "err %ld\n", PTR_ERR(kretprobe_link))) {
kretprobe_link = NULL; kretprobe_link = NULL;

View File

@ -5,12 +5,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <test_progs.h> #include <test_progs.h>
#ifdef __x86_64__
#define SYS_KPROBE_NAME "__x64_sys_nanosleep"
#else
#define SYS_KPROBE_NAME "sys_nanosleep"
#endif
static void on_sample(void *ctx, int cpu, void *data, __u32 size) static void on_sample(void *ctx, int cpu, void *data, __u32 size)
{ {
int cpu_data = *(int *)data, duration = 0; int cpu_data = *(int *)data, duration = 0;
@ -56,7 +50,7 @@ void test_perf_buffer(void)
/* attach kprobe */ /* attach kprobe */
link = bpf_program__attach_kprobe(prog, false /* retprobe */, link = bpf_program__attach_kprobe(prog, false /* retprobe */,
SYS_KPROBE_NAME); SYS_NANOSLEEP_KPROBE_NAME);
if (CHECK(IS_ERR(link), "attach_kprobe", "err %ld\n", PTR_ERR(link))) if (CHECK(IS_ERR(link), "attach_kprobe", "err %ld\n", PTR_ERR(link)))
goto out_close; goto out_close;

View File

@ -92,3 +92,11 @@ int compare_map_keys(int map1_fd, int map2_fd);
int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len); int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len);
int extract_build_id(char *build_id, size_t size); int extract_build_id(char *build_id, size_t size);
void *spin_lock_thread(void *arg); void *spin_lock_thread(void *arg);
#ifdef __x86_64__
#define SYS_NANOSLEEP_KPROBE_NAME "__x64_sys_nanosleep"
#elif defined(__s390x__)
#define SYS_NANOSLEEP_KPROBE_NAME "__s390x_sys_nanosleep"
#else
#define SYS_NANOSLEEP_KPROBE_NAME "sys_nanosleep"
#endif