diff options
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index c941bb640f49..4532a789fbe3 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -283,6 +283,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel, | |||
283 | { | 283 | { |
284 | struct perf_event_attr *attr = &evsel->attr; | 284 | struct perf_event_attr *attr = &evsel->attr; |
285 | struct xyarray *group_fd = NULL; | 285 | struct xyarray *group_fd = NULL; |
286 | bool exclude_guest_missing = false; | ||
287 | int ret; | ||
286 | 288 | ||
287 | if (group && evsel != first) | 289 | if (group && evsel != first) |
288 | group_fd = first->fd; | 290 | group_fd = first->fd; |
@@ -293,16 +295,39 @@ static int create_perf_stat_counter(struct perf_evsel *evsel, | |||
293 | 295 | ||
294 | attr->inherit = !no_inherit; | 296 | attr->inherit = !no_inherit; |
295 | 297 | ||
296 | if (system_wide) | 298 | retry: |
297 | return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, | 299 | if (exclude_guest_missing) |
300 | evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; | ||
301 | |||
302 | if (system_wide) { | ||
303 | ret = perf_evsel__open_per_cpu(evsel, evsel_list->cpus, | ||
298 | group, group_fd); | 304 | group, group_fd); |
305 | if (ret) | ||
306 | goto check_ret; | ||
307 | return 0; | ||
308 | } | ||
309 | |||
299 | if (!target_pid && !target_tid && (!group || evsel == first)) { | 310 | if (!target_pid && !target_tid && (!group || evsel == first)) { |
300 | attr->disabled = 1; | 311 | attr->disabled = 1; |
301 | attr->enable_on_exec = 1; | 312 | attr->enable_on_exec = 1; |
302 | } | 313 | } |
303 | 314 | ||
304 | return perf_evsel__open_per_thread(evsel, evsel_list->threads, | 315 | ret = perf_evsel__open_per_thread(evsel, evsel_list->threads, |
305 | group, group_fd); | 316 | group, group_fd); |
317 | if (!ret) | ||
318 | return 0; | ||
319 | /* fall through */ | ||
320 | check_ret: | ||
321 | if (ret && errno == EINVAL) { | ||
322 | if (!exclude_guest_missing && | ||
323 | (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { | ||
324 | pr_debug("Old kernel, cannot exclude " | ||
325 | "guest or host samples.\n"); | ||
326 | exclude_guest_missing = true; | ||
327 | goto retry; | ||
328 | } | ||
329 | } | ||
330 | return ret; | ||
306 | } | 331 | } |
307 | 332 | ||
308 | /* | 333 | /* |