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


Groups > linux.kernel > #1427111

[PATCH 08/10] perf record: Add --dry-run option to check cmdline options

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 08/10] perf record: Add --dry-run option to check cmdline options
Date 2016-06-21 00:30 +0200
Message-ID <rMfRF-5Ht-57@gated-at.bofh.it> (permalink)
References <rMfRE-5Ht-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Wang Nan <wangnan0@huawei.com>

With '--dry-run', 'perf record' doesn't do reall recording. Combine with
llvm.dump-obj option, --dry-run can be used to help compile BPF objects
for embedded platform.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466064161-48553-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-record.txt | 7 +++++++
 tools/perf/builtin-record.c              | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 8dbee832abd9..5b46b1d1a37c 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -360,6 +360,13 @@ particular perf.data snapshot should be kept or not.
 
 Implies --timestamp-filename, --no-buildid and --no-buildid-cache.
 
+--dry-run::
+Parse options then exit. --dry-run can be used to detect errors in cmdline
+options.
+
+'perf record --dry-run -e' can act as a BPF script compiler if llvm.dump-obj
+in config file is set to true.
+
 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 d4cf1b0c88f9..b1304ebc8779 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1274,6 +1274,8 @@ static struct record record = {
 const char record_callchain_help[] = CALLCHAIN_RECORD_HELP
 	"\n\t\t\t\tDefault: fp";
 
+static bool dry_run;
+
 /*
  * XXX Will stay a global variable till we fix builtin-script.c to stop messing
  * with it and switch to use the library functions in perf_evlist that came
@@ -1393,6 +1395,8 @@ struct option __record_options[] = {
 		    "append timestamp to output filename"),
 	OPT_BOOLEAN(0, "switch-output", &record.switch_output,
 		    "Switch output when receive SIGUSR2"),
+	OPT_BOOLEAN(0, "dry-run", &dry_run,
+		    "Parse options then exit"),
 	OPT_END()
 };
 
@@ -1462,6 +1466,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (err)
 		return err;
 
+	if (dry_run)
+		return 0;
+
 	err = bpf__setup_stdout(rec->evlist);
 	if (err) {
 		bpf__strerror_setup_stdout(rec->evlist, err, errbuf, sizeof(errbuf));
-- 
2.5.5

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


Thread

[GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 04/10] perf hists: Rename __hists__add_entry to hists__add_entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 03/10] perf script: Fix documentation of '-f' when it should be '-F' Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 01/10] perf tools: Find vdso with the consider of cross-platform Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 02/10] kbuild: List libelf-devel as an alternative Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 05/10] perf tools: Remove some unused functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  [PATCH 10/10] perf script: Add stackcollapse.py script Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
    Re: [PATCH 10/10] perf script: Add stackcollapse.py script Brendan Gregg <brendan.d.gregg@gmail.com> - 2016-06-21 20:40 +0200
      Re: [PATCH 10/10] perf script: Add stackcollapse.py script Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 22:40 +0200
  [PATCH 08/10] perf record: Add --dry-run option to check cmdline options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-21 00:30 +0200
  Re: [GIT PULL 00/10] perf/core improvements and fixes Namhyung Kim <namhyung@kernel.org> - 2016-06-21 04:20 +0200
    Re: [GIT PULL 00/10] perf/core improvements and fixes Brendan Gregg <bgregg@netflix.com> - 2016-06-21 05:20 +0200
      Re: [GIT PULL 00/10] perf/core improvements and fixes Paolo Bonzini <pbonzini@redhat.com> - 2016-06-21 12:20 +0200
        Re: [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-06-21 18:20 +0200

csiph-web