From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Zefan Li <lizefan@huawei.com>,
pi3orama@163.com, Wang Nan <wangnan0@huawei.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 09/10] perf evsel: Fix write_backwards fallback
Date: Mon, 20 Jun 2016 19:23:29 -0300 [thread overview]
Message-ID: <1466461410-13778-10-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1466461410-13778-1-git-send-email-acme@kernel.org>
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>
---
tools/perf/util/evsel.c | 23 ++++++++++-------------
1 file 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:
if (perf_missing_features.lbr_flags)
evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
PERF_SAMPLE_BRANCH_NO_CYCLES);
- if (perf_missing_features.write_backward)
+ if (perf_missing_features.write_backward) {
+ if (evsel->overwrite)
+ return -EINVAL;
evsel->attr.write_backward = false;
+ }
retry_sample_id:
if (perf_missing_features.sample_id_all)
evsel->attr.sample_id_all = 0;
@@ -1453,12 +1456,6 @@ retry_open:
err = -EINVAL;
goto out_close;
}
-
- if (evsel->overwrite &&
- perf_missing_features.write_backward) {
- err = -EINVAL;
- goto out_close;
- }
}
}
@@ -1496,7 +1493,10 @@ try_fallback:
* Must probe features in the order they were added to the
* perf_event_attr interface.
*/
- if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
+ if (!perf_missing_features.write_backward && evsel->attr.write_backward) {
+ perf_missing_features.write_backward = true;
+ goto fallback_missing_features;
+ } else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
perf_missing_features.clockid_wrong = true;
goto fallback_missing_features;
} else if (!perf_missing_features.clockid && evsel->attr.use_clockid) {
@@ -1521,12 +1521,7 @@ try_fallback:
PERF_SAMPLE_BRANCH_NO_FLAGS))) {
perf_missing_features.lbr_flags = true;
goto fallback_missing_features;
- } else if (!perf_missing_features.write_backward &&
- evsel->attr.write_backward) {
- perf_missing_features.write_backward = true;
- goto fallback_missing_features;
}
-
out_close:
do {
while (--thread >= 0) {
@@ -2409,6 +2404,8 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
"We found oprofile daemon running, please stop it and try again.");
break;
case EINVAL:
+ if (evsel->overwrite && perf_missing_features.write_backward)
+ return scnprintf(msg, size, "Reading from overwrite event is not supported by this kernel.");
if (perf_missing_features.clockid)
return scnprintf(msg, size, "clockid feature not supported.");
if (perf_missing_features.clockid_wrong)
--
2.5.5
next prev parent reply other threads:[~2016-06-20 22:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 22:23 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 01/10] perf tools: Find vdso with the consider of cross-platform Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 02/10] kbuild: List libelf-devel as an alternative Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 03/10] perf script: Fix documentation of '-f' when it should be '-F' Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 04/10] perf hists: Rename __hists__add_entry to hists__add_entry Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 05/10] perf tools: Remove some unused functions Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 06/10] perf tools: Remove --perf-dir and --work-dir Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 07/10] perf llvm: Allow dump llvm output object file using llvm.dump-obj Arnaldo Carvalho de Melo
2016-06-20 22:23 ` [PATCH 08/10] perf record: Add --dry-run option to check cmdline options Arnaldo Carvalho de Melo
2016-06-20 22:23 ` Arnaldo Carvalho de Melo [this message]
2016-06-20 22:23 ` [PATCH 10/10] perf script: Add stackcollapse.py script Arnaldo Carvalho de Melo
2016-06-21 18:36 ` Brendan Gregg
2016-06-21 20:19 ` Arnaldo Carvalho de Melo
2016-06-21 2:18 ` [GIT PULL 00/10] perf/core improvements and fixes Namhyung Kim
2016-06-21 3:11 ` Brendan Gregg
2016-06-21 10:08 ` Paolo Bonzini
2016-06-21 16:14 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466461410-13778-10-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).