diff options
author | Arnaldo Carvalho de Melo <acme@kernel.org> | 2016-06-20 06:47:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-21 12:18:35 -0400 |
commit | 7da36e94e7fad768ca8640b61ed1f49b284e1dc5 (patch) | |
tree | bb469c4e412e72259e460da85533b7595f9ca5d4 | |
parent | 0aab21363ffa66d6e7340bc50cc5bfae865fd1a6 (diff) |
perf evsel: Fix write_backwards fallback
Commit b90dc17a5d14 "perf evsel: Add overwrite attribute and check
write_backward" misunderstood the 'order' should be obeyed in
__perf_evsel__open.
But the way this was done for attr.write_backwards was buggy, as we need
to check features in the inverse order of their introduction to the
kernel, so that a newer tool checks first the newest perf_event_attr
fields, detecting that the older kernel doesn't have support for them.
Also, we can avoid calling sys_perf_event_open() if we have already
detected the missing of write_backward.
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Fixes: b90dc17a5d14 ("perf evsel: Add overwrite attribute and check write_backward")
Link: http://lkml.kernel.org/r/1466419645-75551-2-git-send-email-wangnan0@huawei.com
Link: http://lkml.kernel.org/r/20160616214724.GI13337@kernel.org
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/evsel.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 9b2e3e624efe..1d8f2bbd38a7 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1389,8 +1389,11 @@ fallback_missing_features: | |||
1389 | if (perf_missing_features.lbr_flags) | 1389 | if (perf_missing_features.lbr_flags) |
1390 | evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS | | 1390 | evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS | |
1391 | PERF_SAMPLE_BRANCH_NO_CYCLES); | 1391 | PERF_SAMPLE_BRANCH_NO_CYCLES); |
1392 | if (perf_missing_features.write_backward) | 1392 | if (perf_missing_features.write_backward) { |
1393 | if (evsel->overwrite) | ||
1394 | return -EINVAL; | ||
1393 | evsel->attr.write_backward = false; | 1395 | evsel->attr.write_backward = false; |
1396 | } | ||
1394 | retry_sample_id: | 1397 | retry_sample_id: |
1395 | if (perf_missing_features.sample_id_all) | 1398 | if (perf_missing_features.sample_id_all) |
1396 | evsel->attr.sample_id_all = 0; | 1399 | evsel->attr.sample_id_all = 0; |
@@ -1453,12 +1456,6 @@ retry_open: | |||
1453 | err = -EINVAL; | 1456 | err = -EINVAL; |
1454 | goto out_close; | 1457 | goto out_close; |
1455 | } | 1458 | } |
1456 | |||
1457 | if (evsel->overwrite && | ||
1458 | perf_missing_features.write_backward) { | ||
1459 | err = -EINVAL; | ||
1460 | goto out_close; | ||
1461 | } | ||
1462 | } | 1459 | } |
1463 | } | 1460 | } |
1464 | 1461 | ||
@@ -1496,7 +1493,10 @@ try_fallback: | |||
1496 | * Must probe features in the order they were added to the | 1493 | * Must probe features in the order they were added to the |
1497 | * perf_event_attr interface. | 1494 | * perf_event_attr interface. |
1498 | */ | 1495 | */ |
1499 | if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) { | 1496 | if (!perf_missing_features.write_backward && evsel->attr.write_backward) { |
1497 | perf_missing_features.write_backward = true; | ||
1498 | goto fallback_missing_features; | ||
1499 | } else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) { | ||
1500 | perf_missing_features.clockid_wrong = true; | 1500 | perf_missing_features.clockid_wrong = true; |
1501 | goto fallback_missing_features; | 1501 | goto fallback_missing_features; |
1502 | } else if (!perf_missing_features.clockid && evsel->attr.use_clockid) { | 1502 | } else if (!perf_missing_features.clockid && evsel->attr.use_clockid) { |
@@ -1521,12 +1521,7 @@ try_fallback: | |||
1521 | PERF_SAMPLE_BRANCH_NO_FLAGS))) { | 1521 | PERF_SAMPLE_BRANCH_NO_FLAGS))) { |
1522 | perf_missing_features.lbr_flags = true; | 1522 | perf_missing_features.lbr_flags = true; |
1523 | goto fallback_missing_features; | 1523 | goto fallback_missing_features; |
1524 | } else if (!perf_missing_features.write_backward && | ||
1525 | evsel->attr.write_backward) { | ||
1526 | perf_missing_features.write_backward = true; | ||
1527 | goto fallback_missing_features; | ||
1528 | } | 1524 | } |
1529 | |||
1530 | out_close: | 1525 | out_close: |
1531 | do { | 1526 | do { |
1532 | while (--thread >= 0) { | 1527 | while (--thread >= 0) { |
@@ -2409,6 +2404,8 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, | |||
2409 | "We found oprofile daemon running, please stop it and try again."); | 2404 | "We found oprofile daemon running, please stop it and try again."); |
2410 | break; | 2405 | break; |
2411 | case EINVAL: | 2406 | case EINVAL: |
2407 | if (evsel->overwrite && perf_missing_features.write_backward) | ||
2408 | return scnprintf(msg, size, "Reading from overwrite event is not supported by this kernel."); | ||
2412 | if (perf_missing_features.clockid) | 2409 | if (perf_missing_features.clockid) |
2413 | return scnprintf(msg, size, "clockid feature not supported."); | 2410 | return scnprintf(msg, size, "clockid feature not supported."); |
2414 | if (perf_missing_features.clockid_wrong) | 2411 | if (perf_missing_features.clockid_wrong) |