diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-12-13 11:13:07 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 14:40:08 -0500 |
commit | 594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1 (patch) | |
tree | 3fb2c1395bafd1799e34443d58adef6c4b65c7fe /tools/perf/builtin-stat.c | |
parent | ce90e3856ba55af4d3d9c9c1168cc624607f6c7c (diff) |
perf evsel: Do missing feature fallbacks in just one place
Instead of doing it in stat, top, record or any other tool that opens
event descriptors.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-vr8hzph83d5t2mdlkf565h84@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index c12655af2b88..ef067c193f93 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -132,8 +132,6 @@ static struct stats walltime_nsecs_stats; | |||
132 | static int create_perf_stat_counter(struct perf_evsel *evsel) | 132 | static int create_perf_stat_counter(struct perf_evsel *evsel) |
133 | { | 133 | { |
134 | struct perf_event_attr *attr = &evsel->attr; | 134 | struct perf_event_attr *attr = &evsel->attr; |
135 | bool exclude_guest_missing = false; | ||
136 | int ret; | ||
137 | 135 | ||
138 | if (scale) | 136 | if (scale) |
139 | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | | 137 | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | |
@@ -141,16 +139,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) | |||
141 | 139 | ||
142 | attr->inherit = !no_inherit; | 140 | attr->inherit = !no_inherit; |
143 | 141 | ||
144 | retry: | 142 | if (perf_target__has_cpu(&target)) |
145 | if (exclude_guest_missing) | 143 | return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel)); |
146 | evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; | ||
147 | |||
148 | if (perf_target__has_cpu(&target)) { | ||
149 | ret = perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel)); | ||
150 | if (ret) | ||
151 | goto check_ret; | ||
152 | return 0; | ||
153 | } | ||
154 | 144 | ||
155 | if (!perf_target__has_task(&target) && | 145 | if (!perf_target__has_task(&target) && |
156 | perf_evsel__is_group_leader(evsel)) { | 146 | perf_evsel__is_group_leader(evsel)) { |
@@ -158,21 +148,7 @@ retry: | |||
158 | attr->enable_on_exec = 1; | 148 | attr->enable_on_exec = 1; |
159 | } | 149 | } |
160 | 150 | ||
161 | ret = perf_evsel__open_per_thread(evsel, evsel_list->threads); | 151 | return perf_evsel__open_per_thread(evsel, evsel_list->threads); |
162 | if (!ret) | ||
163 | return 0; | ||
164 | /* fall through */ | ||
165 | check_ret: | ||
166 | if (ret && errno == EINVAL) { | ||
167 | if (!exclude_guest_missing && | ||
168 | (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { | ||
169 | pr_debug("Old kernel, cannot exclude " | ||
170 | "guest or host samples.\n"); | ||
171 | exclude_guest_missing = true; | ||
172 | goto retry; | ||
173 | } | ||
174 | } | ||
175 | return ret; | ||
176 | } | 152 | } |
177 | 153 | ||
178 | /* | 154 | /* |