diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-10-01 09:03:57 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-10-01 09:03:57 +0200 |
commit | 4bc6a58fcbf63dc3da9870c41eeab1bd030bc585 (patch) | |
tree | 965af8015bcc5a9375e8858bf6aea52f5e45357c /tools/perf/util/evlist.c | |
parent | 9c17dbc6eb73bdd8a6aaea1baefd37ff78d86148 (diff) | |
parent | 7f8d1ade1b19f684ed3a7c4fb1dc5d347127b438 (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes:
User visible changes:
- By default use the most precise "cycles" hw counter available, i.e.
when the user doesn't specify any event, it will try using cycles:ppp,
cycles:pp, etc. (Arnaldo Carvalho de Melo)
- Remove blank lines, headers when piping output in 'perf list', so that it can
be sanely used with 'wc -l', etc. (Arnaldo Carvalho de Melo)
- Amend documentation about max_stack and synthesized callchains. (Adrian Hunter)
- Fix 'perf probe -l' for probes added to kernel module functions. (Masami Hiramatsu)
Build fixes:
- Fix shadowed declarations that break the build on older distros. (Jiri Olsa)
- Fix build break on powerpc due to sample_reg_masks. (Sukadev Bhattiprolu)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r-- | tools/perf/util/evlist.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 89546228b8ed..e7e195d867ea 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -205,6 +205,20 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) } } +static void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr) +{ + attr->precise_ip = 3; + + while (attr->precise_ip != 0) { + int fd = sys_perf_event_open(attr, 0, -1, -1, 0); + if (fd != -1) { + close(fd); + break; + } + --attr->precise_ip; + } +} + int perf_evlist__add_default(struct perf_evlist *evlist) { struct perf_event_attr attr = { @@ -215,13 +229,15 @@ int perf_evlist__add_default(struct perf_evlist *evlist) event_attr_init(&attr); + perf_event_attr__set_max_precise_ip(&attr); + evsel = perf_evsel__new(&attr); if (evsel == NULL) goto error; - /* use strdup() because free(evsel) assumes name is allocated */ - evsel->name = strdup("cycles"); - if (!evsel->name) + /* use asprintf() because free(evsel) assumes name is allocated */ + if (asprintf(&evsel->name, "cycles%.*s", + attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0) goto error_free; perf_evlist__add(evlist, evsel); |