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

perf tests: Switch from open to openat

Multiple perf tests fail on arm64 due to missing open syscall:

2: detect open syscall event : FAILED!

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus
new architectures in kernel, such as arm64, don't implement these legacy
syscalls.

The patch replaces all sys_enter_open events with sys_enter_openat,
renames the related tests and test output to avoid confusion.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429192375-13706-2-git-send-email-riku.voipio@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Riku Voipio and committed by
Arnaldo Carvalho de Melo
43f322b4 3237f281

+31 -31
+6 -6
tools/perf/tests/builtin-test.c
··· 23 23 .func = test__vmlinux_matches_kallsyms, 24 24 }, 25 25 { 26 - .desc = "detect open syscall event", 27 - .func = test__open_syscall_event, 26 + .desc = "detect openat syscall event", 27 + .func = test__openat_syscall_event, 28 28 }, 29 29 { 30 - .desc = "detect open syscall event on all cpus", 31 - .func = test__open_syscall_event_on_all_cpus, 30 + .desc = "detect openat syscall event on all cpus", 31 + .func = test__openat_syscall_event_on_all_cpus, 32 32 }, 33 33 { 34 34 .desc = "read samples using the mmap interface", ··· 73 73 .func = test__perf_evsel__tp_sched_test, 74 74 }, 75 75 { 76 - .desc = "Generate and check syscalls:sys_enter_open event fields", 77 - .func = test__syscall_open_tp_fields, 76 + .desc = "Generate and check syscalls:sys_enter_openat event fields", 77 + .func = test__syscall_openat_tp_fields, 78 78 }, 79 79 { 80 80 .desc = "struct perf_event_attr setup",
+6 -6
tools/perf/tests/open-syscall-all-cpus.c
··· 4 4 #include "cpumap.h" 5 5 #include "debug.h" 6 6 7 - int test__open_syscall_event_on_all_cpus(void) 7 + int test__openat_syscall_event_on_all_cpus(void) 8 8 { 9 9 int err = -1, fd, cpu; 10 10 struct cpu_map *cpus; 11 11 struct perf_evsel *evsel; 12 - unsigned int nr_open_calls = 111, i; 12 + unsigned int nr_openat_calls = 111, i; 13 13 cpu_set_t cpu_set; 14 14 struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); 15 15 char sbuf[STRERR_BUFSIZE]; ··· 27 27 28 28 CPU_ZERO(&cpu_set); 29 29 30 - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); 30 + evsel = perf_evsel__newtp("syscalls", "sys_enter_openat"); 31 31 if (evsel == NULL) { 32 32 if (tracefs_configured()) 33 33 pr_debug("is tracefs mounted on /sys/kernel/tracing?\n"); ··· 46 46 } 47 47 48 48 for (cpu = 0; cpu < cpus->nr; ++cpu) { 49 - unsigned int ncalls = nr_open_calls + cpu; 49 + unsigned int ncalls = nr_openat_calls + cpu; 50 50 /* 51 51 * XXX eventually lift this restriction in a way that 52 52 * keeps perf building on older glibc installations ··· 66 66 goto out_close_fd; 67 67 } 68 68 for (i = 0; i < ncalls; ++i) { 69 - fd = open("/etc/passwd", O_RDONLY); 69 + fd = openat(0, "/etc/passwd", O_RDONLY); 70 70 close(fd); 71 71 } 72 72 CPU_CLR(cpus->map[cpu], &cpu_set); ··· 96 96 break; 97 97 } 98 98 99 - expected = nr_open_calls + cpu; 99 + expected = nr_openat_calls + cpu; 100 100 if (evsel->counts->cpu[cpu].val != expected) { 101 101 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", 102 102 expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
+3 -3
tools/perf/tests/open-syscall-tp-fields.c
··· 5 5 #include "tests.h" 6 6 #include "debug.h" 7 7 8 - int test__syscall_open_tp_fields(void) 8 + int test__syscall_openat_tp_fields(void) 9 9 { 10 10 struct record_opts opts = { 11 11 .target = { ··· 29 29 goto out; 30 30 } 31 31 32 - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); 32 + evsel = perf_evsel__newtp("syscalls", "sys_enter_openat"); 33 33 if (evsel == NULL) { 34 34 pr_debug("%s: perf_evsel__newtp\n", __func__); 35 35 goto out_delete_evlist; ··· 66 66 /* 67 67 * Generate the event: 68 68 */ 69 - open(filename, flags); 69 + openat(AT_FDCWD, filename, flags); 70 70 71 71 while (1) { 72 72 int before = nr_events;
+7 -7
tools/perf/tests/open-syscall.c
··· 3 3 #include "debug.h" 4 4 #include "tests.h" 5 5 6 - int test__open_syscall_event(void) 6 + int test__openat_syscall_event(void) 7 7 { 8 8 int err = -1, fd; 9 9 struct perf_evsel *evsel; 10 - unsigned int nr_open_calls = 111, i; 10 + unsigned int nr_openat_calls = 111, i; 11 11 struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); 12 12 char sbuf[STRERR_BUFSIZE]; 13 13 ··· 16 16 return -1; 17 17 } 18 18 19 - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); 19 + evsel = perf_evsel__newtp("syscalls", "sys_enter_openat"); 20 20 if (evsel == NULL) { 21 21 if (tracefs_configured()) 22 22 pr_debug("is tracefs mounted on /sys/kernel/tracing?\n"); ··· 34 34 goto out_evsel_delete; 35 35 } 36 36 37 - for (i = 0; i < nr_open_calls; ++i) { 38 - fd = open("/etc/passwd", O_RDONLY); 37 + for (i = 0; i < nr_openat_calls; ++i) { 38 + fd = openat(0, "/etc/passwd", O_RDONLY); 39 39 close(fd); 40 40 } 41 41 ··· 44 44 goto out_close_fd; 45 45 } 46 46 47 - if (evsel->counts->cpu[0].val != nr_open_calls) { 47 + if (evsel->counts->cpu[0].val != nr_openat_calls) { 48 48 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n", 49 - nr_open_calls, evsel->counts->cpu[0].val); 49 + nr_openat_calls, evsel->counts->cpu[0].val); 50 50 goto out_close_fd; 51 51 } 52 52
+6 -6
tools/perf/tests/parse-events.c
··· 427 427 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 428 428 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 429 429 430 - /* syscalls:sys_enter_open:k */ 430 + /* syscalls:sys_enter_openat:k */ 431 431 evsel = perf_evsel__next(evsel); 432 432 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 433 433 TEST_ASSERT_VAL("wrong sample_type", ··· 665 665 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); 666 666 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); 667 667 668 - /* group1 syscalls:sys_enter_open:H */ 668 + /* group1 syscalls:sys_enter_openat:H */ 669 669 evsel = leader = perf_evlist__first(evlist); 670 670 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 671 671 TEST_ASSERT_VAL("wrong sample_type", ··· 1293 1293 1294 1294 static struct evlist_test test__events[] = { 1295 1295 { 1296 - .name = "syscalls:sys_enter_open", 1296 + .name = "syscalls:sys_enter_openat", 1297 1297 .check = test__checkevent_tracepoint, 1298 1298 .id = 0, 1299 1299 }, ··· 1353 1353 .id = 11, 1354 1354 }, 1355 1355 { 1356 - .name = "syscalls:sys_enter_open:k", 1356 + .name = "syscalls:sys_enter_openat:k", 1357 1357 .check = test__checkevent_tracepoint_modifier, 1358 1358 .id = 12, 1359 1359 }, ··· 1408 1408 .id = 22, 1409 1409 }, 1410 1410 { 1411 - .name = "r1,syscalls:sys_enter_open:k,1:1:hp", 1411 + .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", 1412 1412 .check = test__checkevent_list, 1413 1413 .id = 23, 1414 1414 }, ··· 1443 1443 .id = 29, 1444 1444 }, 1445 1445 { 1446 - .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1446 + .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1447 1447 .check = test__group3, 1448 1448 .id = 30, 1449 1449 },
+3 -3
tools/perf/tests/tests.h
··· 26 26 27 27 /* Tests */ 28 28 int test__vmlinux_matches_kallsyms(void); 29 - int test__open_syscall_event(void); 30 - int test__open_syscall_event_on_all_cpus(void); 29 + int test__openat_syscall_event(void); 30 + int test__openat_syscall_event_on_all_cpus(void); 31 31 int test__basic_mmap(void); 32 32 int test__PERF_RECORD(void); 33 33 int test__rdpmc(void); 34 34 int test__perf_evsel__roundtrip_name_test(void); 35 35 int test__perf_evsel__tp_sched_test(void); 36 - int test__syscall_open_tp_fields(void); 36 + int test__syscall_openat_tp_fields(void); 37 37 int test__pmu(void); 38 38 int test__attr(void); 39 39 int test__dso_data(void);