diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-04-07 17:25:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-08 10:00:16 -0400 |
commit | a1e12da4796a4ddd0e911687a290eb396d1c64bf (patch) | |
tree | f6b0c0d524a376fa4e0411d08bac307d931f35c9 /tools | |
parent | f6fcc1433a4a9057b2977313f31eadbc1c84268b (diff) |
perf tools: Add 'I' event modifier for exclude_idle bit
Adding 'I' event modifier to have complete set of modifiers for
perf_event_attr:exclude_* bits.
Any event specified with 'I' modifier will have the
perf_event_attr:exclude_idle bit set.
$ perf record -e cycles:I -vv ls 2>&1 | grep exclude_idle
exclude_hv 0 exclude_idle 1
Adding automated tests.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/1428441919-23099-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-list.txt | 1 | ||||
-rw-r--r-- | tools/perf/tests/parse-events.c | 40 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 8 | ||||
-rw-r--r-- | tools/perf/util/parse-events.l | 2 |
4 files changed, 49 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index 4692d277980b..bada8933fdd4 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt | |||
@@ -26,6 +26,7 @@ counted. The following modifiers exist: | |||
26 | u - user-space counting | 26 | u - user-space counting |
27 | k - kernel counting | 27 | k - kernel counting |
28 | h - hypervisor counting | 28 | h - hypervisor counting |
29 | I - non idle counting | ||
29 | G - guest counting (in KVM guests) | 30 | G - guest counting (in KVM guests) |
30 | H - host counting (not in KVM guests) | 31 | H - host counting (not in KVM guests) |
31 | p - precise level | 32 | p - precise level |
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index ac243ebcb20a..3de744961739 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c | |||
@@ -295,6 +295,36 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) | |||
295 | return test__checkevent_genhw(evlist); | 295 | return test__checkevent_genhw(evlist); |
296 | } | 296 | } |
297 | 297 | ||
298 | static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist) | ||
299 | { | ||
300 | struct perf_evsel *evsel = perf_evlist__first(evlist); | ||
301 | |||
302 | TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); | ||
303 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | ||
304 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | ||
305 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | ||
306 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | ||
307 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | ||
308 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | ||
309 | |||
310 | return test__checkevent_symbolic_name(evlist); | ||
311 | } | ||
312 | |||
313 | static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist) | ||
314 | { | ||
315 | struct perf_evsel *evsel = perf_evlist__first(evlist); | ||
316 | |||
317 | TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); | ||
318 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | ||
319 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | ||
320 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | ||
321 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | ||
322 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | ||
323 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | ||
324 | |||
325 | return test__checkevent_symbolic_name(evlist); | ||
326 | } | ||
327 | |||
298 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) | 328 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) |
299 | { | 329 | { |
300 | struct perf_evsel *evsel = perf_evlist__first(evlist); | 330 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
@@ -1494,6 +1524,16 @@ static struct evlist_test test__events[] = { | |||
1494 | .id = 100, | 1524 | .id = 100, |
1495 | }, | 1525 | }, |
1496 | #endif | 1526 | #endif |
1527 | { | ||
1528 | .name = "instructions:I", | ||
1529 | .check = test__checkevent_exclude_idle_modifier, | ||
1530 | .id = 45, | ||
1531 | }, | ||
1532 | { | ||
1533 | .name = "instructions:kIG", | ||
1534 | .check = test__checkevent_exclude_idle_modifier_1, | ||
1535 | .id = 46, | ||
1536 | }, | ||
1497 | }; | 1537 | }; |
1498 | 1538 | ||
1499 | static struct evlist_test test__events_pmu[] = { | 1539 | static struct evlist_test test__events_pmu[] = { |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index fe07573d5ed4..be0655388b38 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -709,6 +709,7 @@ struct event_modifier { | |||
709 | int eh; | 709 | int eh; |
710 | int eH; | 710 | int eH; |
711 | int eG; | 711 | int eG; |
712 | int eI; | ||
712 | int precise; | 713 | int precise; |
713 | int exclude_GH; | 714 | int exclude_GH; |
714 | int sample_read; | 715 | int sample_read; |
@@ -723,6 +724,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, | |||
723 | int eh = evsel ? evsel->attr.exclude_hv : 0; | 724 | int eh = evsel ? evsel->attr.exclude_hv : 0; |
724 | int eH = evsel ? evsel->attr.exclude_host : 0; | 725 | int eH = evsel ? evsel->attr.exclude_host : 0; |
725 | int eG = evsel ? evsel->attr.exclude_guest : 0; | 726 | int eG = evsel ? evsel->attr.exclude_guest : 0; |
727 | int eI = evsel ? evsel->attr.exclude_idle : 0; | ||
726 | int precise = evsel ? evsel->attr.precise_ip : 0; | 728 | int precise = evsel ? evsel->attr.precise_ip : 0; |
727 | int sample_read = 0; | 729 | int sample_read = 0; |
728 | int pinned = evsel ? evsel->attr.pinned : 0; | 730 | int pinned = evsel ? evsel->attr.pinned : 0; |
@@ -753,6 +755,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str, | |||
753 | if (!exclude_GH) | 755 | if (!exclude_GH) |
754 | exclude_GH = eG = eH = 1; | 756 | exclude_GH = eG = eH = 1; |
755 | eH = 0; | 757 | eH = 0; |
758 | } else if (*str == 'I') { | ||
759 | eI = 1; | ||
756 | } else if (*str == 'p') { | 760 | } else if (*str == 'p') { |
757 | precise++; | 761 | precise++; |
758 | /* use of precise requires exclude_guest */ | 762 | /* use of precise requires exclude_guest */ |
@@ -786,6 +790,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, | |||
786 | mod->eh = eh; | 790 | mod->eh = eh; |
787 | mod->eH = eH; | 791 | mod->eH = eH; |
788 | mod->eG = eG; | 792 | mod->eG = eG; |
793 | mod->eI = eI; | ||
789 | mod->precise = precise; | 794 | mod->precise = precise; |
790 | mod->exclude_GH = exclude_GH; | 795 | mod->exclude_GH = exclude_GH; |
791 | mod->sample_read = sample_read; | 796 | mod->sample_read = sample_read; |
@@ -803,7 +808,7 @@ static int check_modifier(char *str) | |||
803 | char *p = str; | 808 | char *p = str; |
804 | 809 | ||
805 | /* The sizeof includes 0 byte as well. */ | 810 | /* The sizeof includes 0 byte as well. */ |
806 | if (strlen(str) > (sizeof("ukhGHpppSD") - 1)) | 811 | if (strlen(str) > (sizeof("ukhGHpppSDI") - 1)) |
807 | return -1; | 812 | return -1; |
808 | 813 | ||
809 | while (*p) { | 814 | while (*p) { |
@@ -839,6 +844,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) | |||
839 | evsel->attr.precise_ip = mod.precise; | 844 | evsel->attr.precise_ip = mod.precise; |
840 | evsel->attr.exclude_host = mod.eH; | 845 | evsel->attr.exclude_host = mod.eH; |
841 | evsel->attr.exclude_guest = mod.eG; | 846 | evsel->attr.exclude_guest = mod.eG; |
847 | evsel->attr.exclude_idle = mod.eI; | ||
842 | evsel->exclude_GH = mod.exclude_GH; | 848 | evsel->exclude_GH = mod.exclude_GH; |
843 | evsel->sample_read = mod.sample_read; | 849 | evsel->sample_read = mod.sample_read; |
844 | 850 | ||
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 94eacb6c1ef7..8895cf3132ab 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l | |||
@@ -101,7 +101,7 @@ num_raw_hex [a-fA-F0-9]+ | |||
101 | name [a-zA-Z_*?][a-zA-Z0-9_*?]* | 101 | name [a-zA-Z_*?][a-zA-Z0-9_*?]* |
102 | name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* | 102 | name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* |
103 | /* If you add a modifier you need to update check_modifier() */ | 103 | /* If you add a modifier you need to update check_modifier() */ |
104 | modifier_event [ukhpGHSD]+ | 104 | modifier_event [ukhpGHSDI]+ |
105 | modifier_bp [rwx]{1,3} | 105 | modifier_bp [rwx]{1,3} |
106 | 106 | ||
107 | %% | 107 | %% |