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

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
a1e12da4 f6fcc143

+49 -2
+1
tools/perf/Documentation/perf-list.txt
··· 26 26 u - user-space counting 27 27 k - kernel counting 28 28 h - hypervisor counting 29 + I - non idle counting 29 30 G - guest counting (in KVM guests) 30 31 H - host counting (not in KVM guests) 31 32 p - precise level
+40
tools/perf/tests/parse-events.c
··· 295 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 328 static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) 299 329 { 300 330 struct perf_evsel *evsel = perf_evlist__first(evlist); ··· 1524 1494 .id = 100, 1525 1495 }, 1526 1496 #endif 1497 + { 1498 + .name = "instructions:I", 1499 + .check = test__checkevent_exclude_idle_modifier, 1500 + .id = 45, 1501 + }, 1502 + { 1503 + .name = "instructions:kIG", 1504 + .check = test__checkevent_exclude_idle_modifier_1, 1505 + .id = 46, 1506 + }, 1527 1507 }; 1528 1508 1529 1509 static struct evlist_test test__events_pmu[] = {
+7 -1
tools/perf/util/parse-events.c
··· 709 709 int eh; 710 710 int eH; 711 711 int eG; 712 + int eI; 712 713 int precise; 713 714 int exclude_GH; 714 715 int sample_read; ··· 724 723 int eh = evsel ? evsel->attr.exclude_hv : 0; 725 724 int eH = evsel ? evsel->attr.exclude_host : 0; 726 725 int eG = evsel ? evsel->attr.exclude_guest : 0; 726 + int eI = evsel ? evsel->attr.exclude_idle : 0; 727 727 int precise = evsel ? evsel->attr.precise_ip : 0; 728 728 int sample_read = 0; 729 729 int pinned = evsel ? evsel->attr.pinned : 0; ··· 755 753 if (!exclude_GH) 756 754 exclude_GH = eG = eH = 1; 757 755 eH = 0; 756 + } else if (*str == 'I') { 757 + eI = 1; 758 758 } else if (*str == 'p') { 759 759 precise++; 760 760 /* use of precise requires exclude_guest */ ··· 790 786 mod->eh = eh; 791 787 mod->eH = eH; 792 788 mod->eG = eG; 789 + mod->eI = eI; 793 790 mod->precise = precise; 794 791 mod->exclude_GH = exclude_GH; 795 792 mod->sample_read = sample_read; ··· 808 803 char *p = str; 809 804 810 805 /* The sizeof includes 0 byte as well. */ 811 - if (strlen(str) > (sizeof("ukhGHpppSD") - 1)) 806 + if (strlen(str) > (sizeof("ukhGHpppSDI") - 1)) 812 807 return -1; 813 808 814 809 while (*p) { ··· 844 839 evsel->attr.precise_ip = mod.precise; 845 840 evsel->attr.exclude_host = mod.eH; 846 841 evsel->attr.exclude_guest = mod.eG; 842 + evsel->attr.exclude_idle = mod.eI; 847 843 evsel->exclude_GH = mod.exclude_GH; 848 844 evsel->sample_read = mod.sample_read; 849 845
+1 -1
tools/perf/util/parse-events.l
··· 101 101 name [a-zA-Z_*?][a-zA-Z0-9_*?]* 102 102 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* 103 103 /* If you add a modifier you need to update check_modifier() */ 104 - modifier_event [ukhpGHSD]+ 104 + modifier_event [ukhpGHSDI]+ 105 105 modifier_bp [rwx]{1,3} 106 106 107 107 %%