From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
Andi Kleen <ak@linux.intel.com>, David Ahern <dsahern@gmail.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Stephane Eranian <eranian@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 02/22] perf record: Add --all-user/--all-kernel options
Date: Fri, 19 Feb 2016 19:41:16 -0300 [thread overview]
Message-ID: <1455921696-3895-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1455921696-3895-1-git-send-email-acme@kernel.org>
From: Jiri Olsa <jolsa@kernel.org>
Allow user to easily switch all events to user or kernel space with simple
--all-user or --all-kernel options.
This will be handy within perf mem/c2c wrappers to switch easily monitoring
modes.
Committer note:
Testing it:
# perf record --all-kernel --all-user -a sleep 2
Error: option `all-user' cannot be used with all-kernel
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--all-user Configure all used events to run in user space.
--all-kernel Configure all used events to run in kernel space.
# perf record --all-user --all-kernel -a sleep 2
Error: option `all-kernel' cannot be used with all-user
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--all-kernel Configure all used events to run in kernel space.
--all-user Configure all used events to run in user space.
# perf record --all-user -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.416 MB perf.data (162 samples) ]
# perf report | grep '\[k\]'
# perf record --all-kernel -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.423 MB perf.data (296 samples) ]
# perf report | grep '\[\.\]'
#
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1455525293-8671-2-git-send-email-jolsa@kernel.org
[ Made those options to be mutually exclusive ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/builtin-record.c | 6 ++++++
tools/perf/perf.h | 2 ++
tools/perf/util/evsel.c | 10 ++++++++++
4 files changed, 24 insertions(+)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index fbceb631387c..19aa17532a16 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -341,6 +341,12 @@ Specify vmlinux path which has debuginfo.
--buildid-all::
Record build-id of all DSOs regardless whether it's actually hit or not.
+--all-kernel::
+Configure all used events to run in kernel space.
+
+--all-user::
+Configure all used events to run in user space.
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0ee0d5cd31a7..cf3a28d83066 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1140,6 +1140,12 @@ struct option __record_options[] = {
"per thread proc mmap processing timeout in ms"),
OPT_BOOLEAN(0, "switch-events", &record.opts.record_switch_events,
"Record context switch events"),
+ OPT_BOOLEAN_FLAG(0, "all-kernel", &record.opts.all_kernel,
+ "Configure all used events to run in kernel space.",
+ PARSE_OPT_EXCLUSIVE),
+ OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
+ "Configure all used events to run in user space.",
+ PARSE_OPT_EXCLUSIVE),
OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
"clang binary to use for compiling BPF scriptlets"),
OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 90129accffbe..5381a01c0610 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -58,6 +58,8 @@ struct record_opts {
bool full_auxtrace;
bool auxtrace_snapshot_mode;
bool record_switch_events;
+ bool all_kernel;
+ bool all_user;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 467808680ee4..6ae20d0056de 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -898,6 +898,16 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
if (evsel->precise_max)
perf_event_attr__set_max_precise_ip(attr);
+ if (opts->all_user) {
+ attr->exclude_kernel = 1;
+ attr->exclude_user = 0;
+ }
+
+ if (opts->all_kernel) {
+ attr->exclude_kernel = 0;
+ attr->exclude_user = 1;
+ }
+
/*
* Apply event specific term settings,
* it overloads any global configuration.
--
2.5.0
next prev parent reply other threads:[~2016-02-19 22:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 22:41 [GIT PULL 00/22] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 01/22] perf evlist: Reference count the cpu and thread maps at set_maps() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` Arnaldo Carvalho de Melo [this message]
2016-02-19 22:41 ` [PATCH 03/22] perf evlist: Handle -EINVAL for sample_freq > max_sample_rate in strerror_open() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 04/22] perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 05/22] perf test: Reduce the sample_freq for the 'object code reading' test Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 06/22] perf stat: Handled scaled == -1 case for counters Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 07/22] perf bpf: Rename bpf_prog_priv__clear() to clear_prog_priv() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 08/22] perf tools: Fix checking asprintf return value Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 09/22] perf tools: Create config_term_names array Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 10/22] perf stat: Bail out on unsupported event config modifiers Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 11/22] perf tools: Rename and move pmu_event_name to get_config_name Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 12/22] perf tools: Introduce opt_event_config nonterminal Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 13/22] perf tools: Enable config raw and numeric events Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 14/22] perf tools: Enable config and setting names for legacy cache events Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 15/22] perf hists browser: Fix percentage update on key press Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 16/22] perf callchain: Check return value of add_child() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 17/22] perf callchain: Check return value of fill_node() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 18/22] perf callchain: Add enum match_result for match_chain() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 19/22] perf callchain: Check return value of split_add_child() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 20/22] perf callchain: Check return value of append_chain_children() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 21/22] perf hists: Return error from hists__collapse_resort() Arnaldo Carvalho de Melo
2016-02-19 22:41 ` [PATCH 22/22] perf report: Check error during report__collapse_hists() Arnaldo Carvalho de Melo
2016-02-20 10:56 ` [GIT PULL 00/22] perf/core improvements and fixes Ingo Molnar
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=1455921696-3895-3-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/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).