aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-10-05 14:06:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-05 15:21:11 -0400
commit7f94af7a489fada17d28cc60e8f4409ce216bd6d (patch)
treeb01ac1104e90dab6b9e8d657658d68dac4b873b7 /tools/perf
parent45cf6c33f95448752dd3d5531388429c3a5012d0 (diff)
perf tools: Introduce 'P' modifier to request max precision
The 'P' will cause the event to get maximum possible detected precise level. Following record: $ perf record -e cycles:P ... will detect maximum precise level for 'cycles' event and use it. Commiter note: Testing it: $ perf record -e cycles:P usleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.013 MB perf.data (9 samples) ] $ perf evlist cycles:P $ perf evlist -v cycles:P: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 2, sample_id_all: 1, mmap2: 1, comm_exec: 1 $ Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1444068369-20978-6-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-list.txt1
-rw-r--r--tools/perf/util/evsel.c3
-rw-r--r--tools/perf/util/evsel.h1
-rw-r--r--tools/perf/util/parse-events.c8
-rw-r--r--tools/perf/util/parse-events.l2
5 files changed, 13 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index ad60c6ea1997..79483f40e991 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -30,6 +30,7 @@ counted. The following modifiers exist:
30 G - guest counting (in KVM guests) 30 G - guest counting (in KVM guests)
31 H - host counting (not in KVM guests) 31 H - host counting (not in KVM guests)
32 p - precise level 32 p - precise level
33 P - use maximum detected precise level
33 S - read sample value (PERF_SAMPLE_READ) 34 S - read sample value (PERF_SAMPLE_READ)
34 D - pin the event to the PMU 35 D - pin the event to the PMU
35 36
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0b1c289da36d..8be867ccefe9 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -882,6 +882,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
882 attr->clockid = opts->clockid; 882 attr->clockid = opts->clockid;
883 } 883 }
884 884
885 if (evsel->precise_max)
886 perf_event_attr__set_max_precise_ip(attr);
887
885 /* 888 /*
886 * Apply event specific term settings, 889 * Apply event specific term settings,
887 * it overloads any global configuration. 890 * it overloads any global configuration.
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 7906666580da..02a5fed8d924 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -111,6 +111,7 @@ struct perf_evsel {
111 bool system_wide; 111 bool system_wide;
112 bool tracking; 112 bool tracking;
113 bool per_pkg; 113 bool per_pkg;
114 bool precise_max;
114 /* parse modifier helper */ 115 /* parse modifier helper */
115 int exclude_GH; 116 int exclude_GH;
116 int nr_members; 117 int nr_members;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5d0cfce2599b..3ed8bf175163 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -923,6 +923,7 @@ struct event_modifier {
923 int eG; 923 int eG;
924 int eI; 924 int eI;
925 int precise; 925 int precise;
926 int precise_max;
926 int exclude_GH; 927 int exclude_GH;
927 int sample_read; 928 int sample_read;
928 int pinned; 929 int pinned;
@@ -938,6 +939,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
938 int eG = evsel ? evsel->attr.exclude_guest : 0; 939 int eG = evsel ? evsel->attr.exclude_guest : 0;
939 int eI = evsel ? evsel->attr.exclude_idle : 0; 940 int eI = evsel ? evsel->attr.exclude_idle : 0;
940 int precise = evsel ? evsel->attr.precise_ip : 0; 941 int precise = evsel ? evsel->attr.precise_ip : 0;
942 int precise_max = 0;
941 int sample_read = 0; 943 int sample_read = 0;
942 int pinned = evsel ? evsel->attr.pinned : 0; 944 int pinned = evsel ? evsel->attr.pinned : 0;
943 945
@@ -974,6 +976,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
974 /* use of precise requires exclude_guest */ 976 /* use of precise requires exclude_guest */
975 if (!exclude_GH) 977 if (!exclude_GH)
976 eG = 1; 978 eG = 1;
979 } else if (*str == 'P') {
980 precise_max = 1;
977 } else if (*str == 'S') { 981 } else if (*str == 'S') {
978 sample_read = 1; 982 sample_read = 1;
979 } else if (*str == 'D') { 983 } else if (*str == 'D') {
@@ -1004,6 +1008,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
1004 mod->eG = eG; 1008 mod->eG = eG;
1005 mod->eI = eI; 1009 mod->eI = eI;
1006 mod->precise = precise; 1010 mod->precise = precise;
1011 mod->precise_max = precise_max;
1007 mod->exclude_GH = exclude_GH; 1012 mod->exclude_GH = exclude_GH;
1008 mod->sample_read = sample_read; 1013 mod->sample_read = sample_read;
1009 mod->pinned = pinned; 1014 mod->pinned = pinned;
@@ -1020,7 +1025,7 @@ static int check_modifier(char *str)
1020 char *p = str; 1025 char *p = str;
1021 1026
1022 /* The sizeof includes 0 byte as well. */ 1027 /* The sizeof includes 0 byte as well. */
1023 if (strlen(str) > (sizeof("ukhGHpppSDI") - 1)) 1028 if (strlen(str) > (sizeof("ukhGHpppPSDI") - 1))
1024 return -1; 1029 return -1;
1025 1030
1026 while (*p) { 1031 while (*p) {
@@ -1059,6 +1064,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add)
1059 evsel->attr.exclude_idle = mod.eI; 1064 evsel->attr.exclude_idle = mod.eI;
1060 evsel->exclude_GH = mod.exclude_GH; 1065 evsel->exclude_GH = mod.exclude_GH;
1061 evsel->sample_read = mod.sample_read; 1066 evsel->sample_read = mod.sample_read;
1067 evsel->precise_max = mod.precise_max;
1062 1068
1063 if (perf_evsel__is_group_leader(evsel)) 1069 if (perf_evsel__is_group_leader(evsel))
1064 evsel->attr.pinned = mod.pinned; 1070 evsel->attr.pinned = mod.pinned;
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index c29832bce496..be244573a02e 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -122,7 +122,7 @@ num_raw_hex [a-fA-F0-9]+
122name [a-zA-Z_*?][a-zA-Z0-9_*?.]* 122name [a-zA-Z_*?][a-zA-Z0-9_*?.]*
123name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]* 123name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]*
124/* If you add a modifier you need to update check_modifier() */ 124/* If you add a modifier you need to update check_modifier() */
125modifier_event [ukhpGHSDI]+ 125modifier_event [ukhpPGHSDI]+
126modifier_bp [rwx]{1,3} 126modifier_bp [rwx]{1,3}
127 127
128%% 128%%