diff options
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/attr/README | 6 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-default | 2 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-dwarf | 2 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-fp | 2 | ||||
-rw-r--r-- | tools/perf/tests/code-reading.c | 17 | ||||
-rw-r--r-- | tools/perf/tests/dso-data.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/evsel-tp-sched.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/hists_link.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/mmap-basic.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-all-cpus.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-tp-fields.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/parse-events.c | 9 | ||||
-rw-r--r-- | tools/perf/tests/perf-record.c | 12 | ||||
-rw-r--r-- | tools/perf/tests/rdpmc.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/sample-parsing.c | 11 | ||||
-rw-r--r-- | tools/perf/tests/sw-clock.c | 15 | ||||
-rw-r--r-- | tools/perf/tests/task-exit.c | 16 |
18 files changed, 59 insertions, 62 deletions
diff --git a/tools/perf/tests/attr/README b/tools/perf/tests/attr/README index 430024f..d102957 100644 --- a/tools/perf/tests/attr/README +++ b/tools/perf/tests/attr/README @@ -44,9 +44,9 @@ Following tests are defined (with perf commands): perf record -c 123 kill (test-record-count) perf record -d kill (test-record-data) perf record -F 100 kill (test-record-freq) - perf record -g kill (test-record-graph-default) - perf record --call-graph dwarf kill (test-record-graph-dwarf) - perf record --call-graph fp kill (test-record-graph-fp) + perf record -g -- kill (test-record-graph-default) + perf record -g dwarf -- kill (test-record-graph-dwarf) + perf record -g fp kill (test-record-graph-fp) perf record --group -e cycles,instructions kill (test-record-group) perf record -e '{cycles,instructions}' kill (test-record-group1) perf record -D kill (test-record-no-delay) diff --git a/tools/perf/tests/attr/test-record-graph-default b/tools/perf/tests/attr/test-record-graph-default index 853597a..833d184 100644 --- a/tools/perf/tests/attr/test-record-graph-default +++ b/tools/perf/tests/attr/test-record-graph-default @@ -1,6 +1,6 @@ [config] command = record -args = -g kill >/dev/null 2>&1 +args = -g -- kill >/dev/null 2>&1 [event:base-record] sample_type=295 diff --git a/tools/perf/tests/attr/test-record-graph-dwarf b/tools/perf/tests/attr/test-record-graph-dwarf index d6f324e..e93e082 100644 --- a/tools/perf/tests/attr/test-record-graph-dwarf +++ b/tools/perf/tests/attr/test-record-graph-dwarf @@ -1,6 +1,6 @@ [config] command = record -args = --call-graph dwarf -- kill >/dev/null 2>&1 +args = -g dwarf -- kill >/dev/null 2>&1 [event:base-record] sample_type=12583 diff --git a/tools/perf/tests/attr/test-record-graph-fp b/tools/perf/tests/attr/test-record-graph-fp index 055e3be..7cef374 100644 --- a/tools/perf/tests/attr/test-record-graph-fp +++ b/tools/perf/tests/attr/test-record-graph-fp @@ -1,6 +1,6 @@ [config] command = record -args = --call-graph fp kill >/dev/null 2>&1 +args = -g fp kill >/dev/null 2>&1 [event:base-record] sample_type=295 diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 85d4919..e3fedfa 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -275,19 +275,8 @@ static int process_event(struct machine *machine, struct perf_evlist *evlist, if (event->header.type == PERF_RECORD_SAMPLE) return process_sample_event(machine, evlist, event, state); - if (event->header.type == PERF_RECORD_THROTTLE || - event->header.type == PERF_RECORD_UNTHROTTLE) - return 0; - - if (event->header.type < PERF_RECORD_MAX) { - int ret; - - ret = machine__process_event(machine, event, NULL); - if (ret < 0) - pr_debug("machine__process_event failed, event type %u\n", - event->header.type); - return ret; - } + if (event->header.type < PERF_RECORD_MAX) + return machine__process_event(machine, event); return 0; } @@ -452,7 +441,7 @@ static int do_test_code_reading(bool try_kcore) } ret = perf_event__synthesize_thread_map(NULL, threads, - perf_event__process, machine, false); + perf_event__process, machine); if (ret < 0) { pr_debug("perf_event__synthesize_thread_map failed\n"); goto out_err; diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 9cc81a3..dffe055 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -35,7 +35,6 @@ static char *test_file(int size) if (size != write(fd, buf, size)) templ = NULL; - free(buf); close(fd); return templ; } diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c index 4774f7f..9b98c15 100644 --- a/tools/perf/tests/evsel-tp-sched.c +++ b/tools/perf/tests/evsel-tp-sched.c @@ -32,7 +32,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, int test__perf_evsel__tp_sched_test(void) { - struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch"); + struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0); int ret = 0; if (evsel == NULL) { @@ -63,7 +63,7 @@ int test__perf_evsel__tp_sched_test(void) perf_evsel__delete(evsel); - evsel = perf_evsel__newtp("sched", "sched_wakeup"); + evsel = perf_evsel__newtp("sched", "sched_wakeup", 0); if (perf_evsel__test_field(evsel, "comm", 16, true)) ret = -1; diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 173bf42..4228ffc 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -93,7 +93,7 @@ static struct machine *setup_fake_machine(struct machines *machines) if (thread == NULL) goto out; - thread__set_comm(thread, fake_threads[i].comm, 0); + thread__set_comm(thread, fake_threads[i].comm); } for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) { @@ -110,7 +110,7 @@ static struct machine *setup_fake_machine(struct machines *machines) strcpy(fake_mmap_event.mmap.filename, fake_mmap_info[i].filename); - machine__process_mmap_event(machine, &fake_mmap_event, NULL); + machine__process_mmap_event(machine, &fake_mmap_event); } for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) { @@ -222,8 +222,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) &sample) < 0) goto out; - he = __hists__add_entry(&evsel->hists, &al, NULL, - NULL, NULL, 1, 1, 0); + he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1); if (he == NULL) goto out; @@ -245,8 +244,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) &sample) < 0) goto out; - he = __hists__add_entry(&evsel->hists, &al, NULL, - NULL, NULL, 1, 1, 0); + he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1); if (he == NULL) goto out; @@ -421,7 +419,7 @@ static void print_hists(struct hists *hists) he = rb_entry(node, struct hist_entry, rb_node_in); pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", - i, thread__comm_str(he->thread), he->ms.map->dso->short_name, + i, he->thread->comm, he->ms.map->dso->short_name, he->ms.sym->name, he->stat.period); i++; @@ -467,7 +465,7 @@ int test__hists_link(void) goto out; list_for_each_entry(evsel, &evlist->entries, node) { - hists__collapse_resort(&evsel->hists, NULL); + hists__collapse_resort(&evsel->hists); if (verbose > 2) print_hists(&evsel->hists); diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index d64ab79..a7232c2 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -65,7 +65,7 @@ int test__basic_mmap(void) char name[64]; snprintf(name, sizeof(name), "sys_enter_%s", syscall_names[i]); - evsels[i] = perf_evsel__newtp("syscalls", name); + evsels[i] = perf_evsel__newtp("syscalls", name, i); if (evsels[i] == NULL) { pr_debug("perf_evsel__new\n"); goto out_free_evlist; diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c index 5fecdbd..b0657a9 100644 --- a/tools/perf/tests/open-syscall-all-cpus.c +++ b/tools/perf/tests/open-syscall-all-cpus.c @@ -26,7 +26,7 @@ int test__open_syscall_event_on_all_cpus(void) CPU_ZERO(&cpu_set); - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); + evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); if (evsel == NULL) { pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); goto out_thread_map_delete; diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index 41cc0ba..524b221 100644 --- a/tools/perf/tests/open-syscall-tp-fields.c +++ b/tools/perf/tests/open-syscall-tp-fields.c @@ -27,7 +27,7 @@ int test__syscall_open_tp_fields(void) goto out; } - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); + evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); if (evsel == NULL) { pr_debug("%s: perf_evsel__newtp\n", __func__); goto out_delete_evlist; diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c index c1dc7d2..befc067 100644 --- a/tools/perf/tests/open-syscall.c +++ b/tools/perf/tests/open-syscall.c @@ -15,7 +15,7 @@ int test__open_syscall_event(void) return -1; } - evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); + evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); if (evsel == NULL) { pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); goto out_thread_map_delete; diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 3cbd104..48114d1 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -2,7 +2,7 @@ #include "parse-events.h" #include "evsel.h" #include "evlist.h" -#include "fs.h" +#include "sysfs.h" #include <lk/debugfs.h> #include "tests.h" #include <linux/hw_breakpoint.h> @@ -441,8 +441,9 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist) static int test__checkevent_pmu_events(struct perf_evlist *evlist) { - struct perf_evsel *evsel = perf_evlist__first(evlist); + struct perf_evsel *evsel; + evsel = list_entry(evlist->entries.next, struct perf_evsel, node); TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); TEST_ASSERT_VAL("wrong exclude_user", @@ -1455,7 +1456,7 @@ static int test_pmu(void) int ret; snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", - sysfs__mountpoint()); + sysfs_find_mountpoint()); ret = stat(path, &st); if (ret) @@ -1472,7 +1473,7 @@ static int test_pmu_events(void) int ret; snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", - sysfs__mountpoint()); + sysfs_find_mountpoint()); ret = stat(path, &st); if (ret) { diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 93a62b0..7923b06 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -45,7 +45,7 @@ int test__PERF_RECORD(void) }; cpu_set_t cpu_mask; size_t cpu_mask_size = sizeof(cpu_mask); - struct perf_evlist *evlist = perf_evlist__new_default(); + struct perf_evlist *evlist = perf_evlist__new(); struct perf_evsel *evsel; struct perf_sample sample; const char *cmd = "sleep"; @@ -66,6 +66,16 @@ int test__PERF_RECORD(void) } /* + * We need at least one evsel in the evlist, use the default + * one: "cycles". + */ + err = perf_evlist__add_default(evlist); + if (err < 0) { + pr_debug("Not enough memory to create evsel\n"); + goto out_delete_evlist; + } + + /* * Create maps of threads and cpus to monitor. In this case * we start with all threads and cpus (-1, -1) but then in * perf_evlist__prepare_workload we'll fill in the only thread diff --git a/tools/perf/tests/rdpmc.c b/tools/perf/tests/rdpmc.c index 46649c2..ff94886 100644 --- a/tools/perf/tests/rdpmc.c +++ b/tools/perf/tests/rdpmc.c @@ -9,6 +9,8 @@ #if defined(__x86_64__) || defined(__i386__) +#define barrier() asm volatile("" ::: "memory") + static u64 rdpmc(unsigned int counter) { unsigned int low, high; diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 1b67720..77f598d 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -121,9 +121,6 @@ static bool samples_same(const struct perf_sample *s1, if (type & PERF_SAMPLE_DATA_SRC) COMP(data_src); - if (type & PERF_SAMPLE_TRANSACTION) - COMP(transaction); - return true; } @@ -168,7 +165,6 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format) .cpu = 110, .raw_size = sizeof(raw_data), .data_src = 111, - .transaction = 112, .raw_data = (void *)raw_data, .callchain = &callchain.callchain, .branch_stack = &branch_stack.branch_stack, @@ -277,11 +273,10 @@ int test__sample_parsing(void) /* * Fail the test if it has not been updated when new sample format bits - * were added. Please actually update the test rather than just change - * the condition below. + * were added. */ - if (PERF_SAMPLE_MAX > PERF_SAMPLE_TRANSACTION << 1) { - pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n"); + if (PERF_SAMPLE_MAX > PERF_SAMPLE_IDENTIFIER << 1) { + pr_debug("sample format has changed - test needs updating\n"); return -1; } diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 6664a7c..6e2b44e 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c @@ -9,7 +9,7 @@ #include "util/cpumap.h" #include "util/thread_map.h" -#define NR_LOOPS 10000000 +#define NR_LOOPS 1000000 /* * This test will open software clock events (cpu-clock, task-clock) @@ -34,7 +34,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) .freq = 1, }; - attr.sample_freq = 500; + attr.sample_freq = 10000; evlist = perf_evlist__new(); if (evlist == NULL) { @@ -42,7 +42,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) return -1; } - evsel = perf_evsel__new(&attr); + evsel = perf_evsel__new(&attr, 0); if (evsel == NULL) { pr_debug("perf_evsel__new\n"); goto out_free_evlist; @@ -57,14 +57,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) goto out_delete_maps; } - if (perf_evlist__open(evlist)) { - const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate"; - - err = -errno; - pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", - strerror(errno), knob, (u64)attr.sample_freq); - goto out_delete_maps; - } + perf_evlist__open(evlist); err = perf_evlist__mmap(evlist, 128, true); if (err < 0) { diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index d09ab57..a3e6487 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -28,7 +28,7 @@ int test__task_exit(void) union perf_event *event; struct perf_evsel *evsel; struct perf_evlist *evlist; - struct target target = { + struct perf_target target = { .uid = UINT_MAX, .uses_mmap = true, }; @@ -37,11 +37,20 @@ int test__task_exit(void) signal(SIGCHLD, sig_handler); signal(SIGUSR1, sig_handler); - evlist = perf_evlist__new_default(); + evlist = perf_evlist__new(); if (evlist == NULL) { - pr_debug("perf_evlist__new_default\n"); + pr_debug("perf_evlist__new\n"); return -1; } + /* + * We need at least one evsel in the evlist, use the default + * one: "cycles". + */ + err = perf_evlist__add_default(evlist); + if (err < 0) { + pr_debug("Not enough memory to create evsel\n"); + goto out_free_evlist; + } /* * Create maps of threads and cpus to monitor. In this case @@ -108,6 +117,7 @@ out_close_evlist: perf_evlist__close(evlist); out_delete_maps: perf_evlist__delete_maps(evlist); +out_free_evlist: perf_evlist__delete(evlist); return err; } |