Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338690

[tip:perf/core] perf record: Add --all-user/--all-kernel options

From tip-bot for Jiri Olsa <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf record: Add --all-user/--all-kernel options
Date 2016-02-20 12:40 +0100
Message-ID <r4e3g-4EY-15@gated-at.bofh.it> (permalink)
References <r2mRm-6Rc-49@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  85723885feb823b4fc352b727ece0b6d00306c4d
Gitweb:     http://git.kernel.org/tip/85723885feb823b4fc352b727ece0b6d00306c4d
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 15 Feb 2016 09:34:31 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 18 Feb 2016 10:48:44 -0300

perf record: Add --all-user/--all-kernel options

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 fbceb63..19aa175 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 0ee0d5c..cf3a28d 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 90129ac..5381a01 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 4678086..6ae20d0 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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/23] perf tools: Several memory events updates Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 10/23] perf x86 intel: Add DATALA events into sysfs Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 11/23] perf mem: Add Intel DATALA memory events Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 18/23] perf tools: Change perf_mem__lvl_scnprintf to return nb of displayed bytes Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 13/23] perf tools: Introduce perf_mem__tlb_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 09/23] perf mem: Add -u/-k options Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 03/23] perf tools: Introduce cl_offset function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 06/23] perf mem: Check for memory events support Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 15/23] perf tools: Introduce perf_mem__snp_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 01/23] perf record: Add --all-user/--all-kernel options Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
    Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-16 18:00 +0100
      Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Andi Kleen <ak@linux.intel.com> - 2016-02-17 04:20 +0100
        Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-17 15:30 +0100
          Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Andi Kleen <ak@linux.intel.com> - 2016-02-17 16:40 +0100
      Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Jiri Olsa <jolsa@redhat.com> - 2016-02-17 15:40 +0100
        Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-17 16:00 +0100
    [tip:perf/core] perf record: Add --all-user/--all-kernel options tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-20 12:40 +0100
  [PATCH 17/23] perf tools: Change perf_mem__tlb_scnprintf to return nb of displayed bytes Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 23/23] perf script: Display data_src values Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 05/23] perf mem: Add -e record option Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 14/23] perf tools: Introduce perf_mem__lvl_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 21/23] perf script: Add data_src and weight column definitions Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
  [PATCH 07/23] perf mem: Introduce perf_mem_events__name function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100
  [PATCH 04/23] perf tools: Add monitored events array Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100
  [PATCH 02/23] perf tools: Make cl_address global Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100

csiph-web