11 #include <sys/types.h> 14 #include <linux/kernel.h> 15 #include <linux/hw_breakpoint.h> 16 #include <api/fs/tracing_path.h> 18 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ 19 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) 43 PERF_TYPE_TRACEPOINT == evsel->
attr.type);
47 1 == evsel->
attr.sample_period);
79 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
90 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
96 0 == evsel->
attr.sample_period);
98 0 == evsel->
attr.config1);
100 1 == evsel->
attr.config2);
111 PERF_COUNT_SW_PAGE_FAULTS == evsel->
attr.config);
132 TEST_ASSERT_VAL(
"wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
133 evsel->
attr.bp_type);
147 HW_BREAKPOINT_X == evsel->
attr.bp_type);
158 PERF_TYPE_BREAKPOINT == evsel->
attr.type);
161 HW_BREAKPOINT_R == evsel->
attr.bp_type);
163 HW_BREAKPOINT_LEN_4 == evsel->
attr.bp_len);
173 PERF_TYPE_BREAKPOINT == evsel->
attr.type);
176 HW_BREAKPOINT_W == evsel->
attr.bp_type);
178 HW_BREAKPOINT_LEN_4 == evsel->
attr.bp_len);
188 PERF_TYPE_BREAKPOINT == evsel->
attr.type);
191 (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->
attr.bp_type);
193 HW_BREAKPOINT_LEN_4 == evsel->
attr.bp_len);
218 !evsel->
attr.exclude_user);
220 evsel->
attr.exclude_kernel);
528 !evsel->
attr.exclude_user);
530 evsel->
attr.exclude_kernel);
546 !evsel->
attr.exclude_user);
548 evsel->
attr.exclude_kernel);
558 !evsel->
attr.exclude_user);
560 evsel->
attr.exclude_kernel);
622 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
638 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
664 PERF_COUNT_SW_PAGE_FAULTS == evsel->
attr.config);
680 PERF_COUNT_HW_CACHE_REFERENCES == evsel->
attr.config);
695 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
738 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
755 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
787 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
811 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
829 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
855 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
872 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
887 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
904 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
918 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
941 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
957 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
981 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
997 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
1021 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
1037 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
1061 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
1077 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
1100 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
1115 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
1129 PERF_COUNT_HW_BRANCH_MISSES == evsel->
attr.config);
1153 PERF_COUNT_HW_INSTRUCTIONS == evsel->
attr.config);
1168 PERF_COUNT_HW_BRANCH_MISSES == evsel->
attr.config);
1205 PERF_COUNT_HW_CPU_CYCLES == evsel->
attr.config);
1214 PERF_COUNT_HW_CACHE_MISSES == evsel->
attr.config);
1220 PERF_COUNT_HW_BRANCH_MISSES == evsel->
attr.config);
1233 TEST_ASSERT_VAL(
"wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
1234 evsel->
attr.bp_type);
1236 evsel->
attr.bp_len);
1249 evsel->
attr.bp_type);
1251 evsel->
attr.bp_len);
1276 PERF_COUNT_SW_TASK_CLOCK == evsel->
attr.config);
1322 struct dirent *events_ent;
1326 events_dir = tracing_events__opendir();
1330 while ((events_ent = readdir(events_dir))) {
1332 struct dirent *sys_ent;
1335 if (!strcmp(events_ent->d_name,
".")
1336 || !strcmp(events_ent->d_name,
"..")
1337 || !strcmp(events_ent->d_name,
"enable")
1338 || !strcmp(events_ent->d_name,
"header_event")
1339 || !strcmp(events_ent->d_name,
"header_page"))
1342 sys_path = get_events_file(events_ent->d_name);
1345 sys_dir = opendir(sys_path);
1348 while ((sys_ent = readdir(sys_dir))) {
1349 if (!strcmp(sys_ent->d_name,
".")
1350 || !strcmp(sys_ent->d_name,
"..")
1351 || !strcmp(sys_ent->d_name,
"enable")
1352 || !strcmp(sys_ent->d_name,
"filter"))
1359 put_events_file(sys_path);
1362 closedir(events_dir);
1383 .
name =
"syscalls:sys_enter_openat",
1388 .name =
"syscalls:*",
1403 .name =
"instructions",
1408 .name =
"cycles/period=100000,config2/",
1418 .name =
"L1-dcache-load-miss",
1443 .name =
"syscalls:sys_enter_openat:k",
1448 .name =
"syscalls:*:u",
1463 .name =
"instructions:h",
1473 .name =
"L1-dcache-load-miss:kp",
1483 .name =
"mem:0:x:k",
1488 .name =
"mem:0:r:hp",
1493 .name =
"mem:0:w:up",
1498 .name =
"r1,syscalls:sys_enter_openat:k,1:1:hp",
1503 .name =
"instructions:G",
1508 .name =
"instructions:H",
1518 .name =
"mem:0:rw:kp",
1523 .name =
"{instructions:k,cycles:upp}",
1528 .name =
"{faults:k,cache-references}:u,cycles:k",
1533 .name =
"group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
1538 .name =
"{cycles:u,instructions:kp}:p",
1543 .name =
"{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1553 .name =
"{cycles,cache-misses:G}:H",
1558 .name =
"{cycles,cache-misses:H}:G",
1563 .name =
"{cycles:G,cache-misses:H}:u",
1568 .name =
"{cycles:G,cache-misses:H}:uG",
1573 .name =
"{cycles,cache-misses,branch-misses}:S",
1578 .name =
"{instructions,branch-misses}:Su",
1583 .name =
"instructions:uDp",
1588 .name =
"{cycles,cache-misses,branch-misses}:D",
1598 .name =
"mem:0/2:w",
1603 .name =
"mem:0/4:rw:u",
1607 #if defined(__s390x__) 1609 .name =
"kvm-s390:kvm_s390_create_vm",
1615 .name =
"instructions:I",
1620 .name =
"instructions:kIG",
1625 .name =
"task-clock:P,cycles",
1630 .name =
"instructions/name=insn/",
1635 .name =
"r1234/name=rawpmu/",
1640 .name =
"4:0x6530160/name=numpmu/",
1645 .name =
"L1-dcache-misses/name=cachepmu/",
1650 .name =
"intel_pt//u",
1658 .
name =
"cpu/config=10,config1,config2=3,period=1000/u",
1663 .name =
"cpu/config=1,name=krava/u,cpu/config=2/u",
1668 .name =
"cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
1682 .
str =
"config=10,config1,config2=3,umask=1",
1698 pr_debug(
"failed to parse event '%s', err %d\n",
1701 ret = e->
check(evlist);
1714 for (i = 0; i < cnt; i++) {
1728 struct list_head terms;
1731 INIT_LIST_HEAD(&terms);
1735 pr_debug(
"failed to parse terms '%s', err %d\n",
1740 ret = t->
check(&terms);
1751 for (i = 0; i < cnt; i++) {
1769 snprintf(path,
PATH_MAX,
"%s/bus/event_source/devices/cpu/format/",
1770 sysfs__mountpoint());
1772 ret = stat(path, &st);
1774 pr_debug(
"omitting PMU cpu tests\n");
1786 snprintf(path,
PATH_MAX,
"%s/bus/event_source/devices/cpu/events/",
1787 sysfs__mountpoint());
1789 ret = stat(path, &st);
1791 pr_debug(
"omitting PMU cpu events tests\n");
1795 dir = opendir(path);
1797 pr_debug(
"can't open pmu event dir");
1801 while (!ret && (ent = readdir(dir))) {
1803 char name[2 * NAME_MAX + 1 + 12 + 3];
1806 if (strchr(ent->d_name,
'.'))
1809 snprintf(name,
sizeof(name),
"cpu/event=%s/u", ent->d_name);
1817 snprintf(name,
sizeof(name),
"%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
1831 #define TEST_EVENTS(tests) \ 1833 ret1 = test_events(tests, ARRAY_SIZE(tests)); \ 1849 ret1 =
test_terms(test__terms, ARRAY_SIZE(test__terms));
#define PERF_TP_SAMPLE_TYPE
static int test_pmu(void)
struct perf_probe_event events[MAX_PROBES]
void parse_events_terms__purge(struct list_head *terms)
static int test_pmu_events(void)
static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
int parse_events_terms(struct list_head *terms, const char *str)
static struct terms_test test__terms[]
static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist)
static int test__pinned_group(struct perf_evlist *evlist)
static int test__checkevent_pmu_events(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_len(struct perf_evlist *evlist)
static int test__group_gh2(struct perf_evlist *evlist)
static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
#define TEST_ASSERT_VAL(text, cond)
static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist)
static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
static int test__checkevent_numeric_modifier(struct perf_evlist *evlist)
void perf_evlist__delete(struct perf_evlist *evlist)
static int test__intel_pt(struct perf_evlist *evlist)
static int test__group_gh4(struct perf_evlist *evlist)
static int term(yyscan_t scanner, int type)
static int test_event(struct evlist_test *e)
static int test__group5(struct perf_evlist *evlist __maybe_unused)
static int test__checkterms_simple(struct list_head *terms)
static int test__checkevent_breakpoint_x(struct perf_evlist *evlist)
union parse_events_term::@132 val
static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist)
int parse_events(struct perf_evlist *evlist, const char *str, struct parse_events_error *err)
static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist)
int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
static struct perf_evsel * perf_evsel__next(struct perf_evsel *evsel)
static int test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlist)
static int test__checkevent_tracepoint(struct perf_evlist *evlist)
static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
struct perf_evlist * evlist
static int test__group3(struct perf_evlist *evlist __maybe_unused)
#define pr_debug(fmt,...)
#define evlist__for_each_entry(evlist, evsel)
static int test__checkevent_config_symbol(struct perf_evlist *evlist)
static int test__group_gh3(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
static int test__checkevent_pinned_modifier(struct perf_evlist *evlist)
static int test_terms(struct terms_test *terms, unsigned cnt)
static int test_events(struct evlist_test *events, unsigned cnt)
static int test__all_tracepoints(struct perf_evlist *evlist)
static int test__checkevent_pmu(struct perf_evlist *evlist)
int(* check)(struct list_head *terms)
static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist)
static int test__group1(struct perf_evlist *evlist)
static int test__checkevent_symbolic_alias(struct perf_evlist *evlist)
static int test__checkevent_config_cache(struct perf_evlist *evlist)
static int test__checkevent_genhw(struct perf_evlist *evlist)
const char * perf_evsel__name(struct perf_evsel *evsel)
static int test__checkevent_pmu_name(struct perf_evlist *evlist)
static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused)
static int test__checkevent_breakpoint_w(struct perf_evlist *evlist)
static int perf_evsel__group_idx(struct perf_evsel *evsel)
static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
static struct perf_evsel * perf_evlist__first(struct perf_evlist *evlist)
static int test__checkevent_breakpoint(struct perf_evlist *evlist)
static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist)
static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
static int test__group2(struct perf_evlist *evlist)
#define TEST_EVENTS(tests)
struct perf_evsel * leader
static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
static int test__checkevent_raw(struct perf_evlist *evlist)
static int count_tracepoints(void)
static int test__group_gh1(struct perf_evlist *evlist)
static int test_term(struct terms_test *t)
static int test__checkevent_config_num(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_r(struct perf_evlist *evlist)
static struct evlist_test test__events[]
static struct evlist_test test__events_pmu[]
static bool perf_evsel__is_group_leader(const struct perf_evsel *evsel)
static int test__leader_sample1(struct perf_evlist *evlist)
static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist)
int(* check)(struct perf_evlist *evlist)
static int test__checkevent_numeric(struct perf_evlist *evlist)
static int test__checkevent_config_raw(struct perf_evlist *evlist)
static bool evsel__has_callchain(const struct perf_evsel *evsel)
static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist)
static int test__group4(struct perf_evlist *evlist __maybe_unused)
static int test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist)
static int test__checkevent_list(struct perf_evlist *evlist)
static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist)
static int test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)
struct perf_evlist * perf_evlist__new(void)
struct perf_event_attr attr
static int test__checkevent_symbolic_name(struct perf_evlist *evlist)