perf evsel: Fix write_backwards fallback
authorArnaldo Carvalho de Melo <acme@kernel.org>
Mon, 20 Jun 2016 10:47:18 +0000 (10:47 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 21 Jun 2016 16:18:35 +0000 (13:18 -0300)
commit7da36e94e7fad768ca8640b61ed1f49b284e1dc5
treebb469c4e412e72259e460da85533b7595f9ca5d4
parent0aab21363ffa66d6e7340bc50cc5bfae865fd1a6
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>
tools/perf/util/evsel.c