diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2015-08-13 11:40:56 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-08-17 16:08:37 +0200 |
commit | 835095653ebfe4b16596a30db1c4e7c414014b5e (patch) | |
tree | 4afc6f2ac74109a8952745cb1c0748c3bad9de6f /tools/perf/util/record.c | |
parent | perf symbols: Fix annotation of vdso (diff) | |
download | linux-835095653ebfe4b16596a30db1c4e7c414014b5e.tar.xz linux-835095653ebfe4b16596a30db1c4e7c414014b5e.zip |
perf tools: Add a helper function to probe whether cpu-wide tracing is possible
Add a helper function to probe whether cpu-wide tracing is possible.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1439458857-30636-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/record.c')
-rw-r--r-- | tools/perf/util/record.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 0d228a29526d..0467367dc315 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -105,6 +105,30 @@ bool perf_can_record_switch_events(void) return perf_probe_api(perf_probe_context_switch); } +bool perf_can_record_cpu_wide(void) +{ + struct perf_event_attr attr = { + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_CPU_CLOCK, + .exclude_kernel = 1, + }; + struct cpu_map *cpus; + int cpu, fd; + + cpus = cpu_map__new(NULL); + if (!cpus) + return false; + cpu = cpus->map[0]; + cpu_map__put(cpus); + + fd = sys_perf_event_open(&attr, -1, cpu, -1, 0); + if (fd < 0) + return false; + close(fd); + + return true; +} + void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) { struct perf_evsel *evsel; |