From: tip-bot for Adrian Hunter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, jolsa@redhat.com, adrian.hunter@intel.com,
acme@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org,
tglx@linutronix.de
Subject: [tip:perf/core] perf tools: Add a helper function to probe whether cpu-wide tracing is possible
Date: Thu, 20 Aug 2015 02:56:41 -0700 [thread overview]
Message-ID: <tip-835095653ebfe4b16596a30db1c4e7c414014b5e@git.kernel.org> (raw)
In-Reply-To: <1439458857-30636-2-git-send-email-adrian.hunter@intel.com>
Commit-ID: 835095653ebfe4b16596a30db1c4e7c414014b5e
Gitweb: http://git.kernel.org/tip/835095653ebfe4b16596a30db1c4e7c414014b5e
Author: Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Thu, 13 Aug 2015 12:40:56 +0300
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 17 Aug 2015 11:08:37 -0300
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>
---
tools/perf/util/evlist.h | 1 +
tools/perf/util/record.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 3977570..436e358 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -115,6 +115,7 @@ void perf_evlist__close(struct perf_evlist *evlist);
void perf_evlist__set_id_pos(struct perf_evlist *evlist);
bool perf_can_sample_identifier(void);
bool perf_can_record_switch_events(void);
+bool perf_can_record_cpu_wide(void);
void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts);
int record_opts__config(struct record_opts *opts);
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index 0d228a2..0467367 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;
next prev parent reply other threads:[~2015-08-20 9:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 9:40 [PATCH 0/2] perf tools: Add support for PERF_RECORD_SWITCH to Intel PT Adrian Hunter
2015-08-13 9:40 ` [PATCH 1/2] perf tools: Add a helper function to probe whether cpu-wide tracing is possible Adrian Hunter
2015-08-20 9:56 ` tip-bot for Adrian Hunter [this message]
2015-08-13 9:40 ` [PATCH 2/2] perf tools: Add support for PERF_RECORD_SWITCH to Intel PT Adrian Hunter
2015-09-02 13:09 ` Adrian Hunter
2015-09-08 14:38 ` [tip:perf/core] perf intel-pt: Add support for PERF_RECORD_SWITCH tip-bot for Adrian Hunter
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=tip-835095653ebfe4b16596a30db1c4e7c414014b5e@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.