From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Adrian Hunter <adrian.hunter@intel.com>,
Andi Kleen <ak@linux.intel.com>,
Stephane Eranian <eranian@google.com>,
Alexey Budankov <alexey.budankov@linux.intel.com>
Subject: [PATCH 4/5] perf record: Add --output-dir option to store data in directory
Date: Sun, 10 Mar 2019 16:30:25 +0100 [thread overview]
Message-ID: <20190310153026.8661-5-jolsa@kernel.org> (raw)
In-Reply-To: <20190310153026.8661-1-jolsa@kernel.org>
Adding --output-dir option to mimic -o and --dir options.
following commands do the same:
$ perf record -o perf.dir.data --dir ...
$ perf record --output-dir perf.dir.data ...
User cannot use both -o and output-dir together,
error is displayed.
Link: http://lkml.kernel.org/n/tip-76ldd2ss6vjvlnjgwy7wxfzt@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/subcmd/parse-options.h | 4 ++++
tools/perf/Documentation/perf-record.txt | 3 +++
tools/perf/builtin-record.c | 13 +++++++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index af9def589863..8a3be77a3346 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -146,6 +146,10 @@ struct option {
.value = check_vtype(v, const char **), .argh = (a), .help = (h), \
.flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
.set = check_vtype(os, bool *)}
+#define OPT_STRING_SET(s, l, v, os, a, h) \
+ { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
+ .value = check_vtype(v, const char **), .argh = (a), .help = (h), \
+ .set = check_vtype(os, bool *)}
#define OPT_STRING_NOEMPTY(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), .argh = (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
#define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 445b7a4eb130..aac609887fb7 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -527,6 +527,9 @@ Implies --tail-synthesize.
--dir::
Store data into directory with one data file for cpu.
+--output-dir::
+Same as --dir option, can't be used together with -o option.
+
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 26981be13aa0..115316e94b34 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -80,6 +80,7 @@ struct record {
bool buildid_all;
bool timestamp_filename;
bool timestamp_boundary;
+ bool output_is_file;
struct switch_output switch_output;
unsigned long long samples;
cpu_set_t affinity_mask;
@@ -1921,8 +1922,10 @@ static struct option __record_options[] = {
OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu",
"list of cpus to monitor"),
OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"),
- OPT_STRING('o', "output", &record.data.path, "file",
- "output file name"),
+ OPT_STRING_SET('o', "output", &record.data.path, &record.output_is_file,
+ "file", "output file name"),
+ OPT_STRING_SET(0, "output-dir", &record.data.path, &record.data.is_dir,
+ "file", "output directory name"),
OPT_BOOLEAN_SET('i', "no-inherit", &record.opts.no_inherit,
&record.opts.no_inherit_set,
"child tasks do not inherit counters"),
@@ -2101,6 +2104,12 @@ int cmd_record(int argc, const char **argv)
"cgroup monitoring only available in system-wide mode");
}
+
+ if (perf_data__is_dir(&rec->data) && record.output_is_file) {
+ ui__error("cannot use both -o and --output-dir\n");
+ return -EINVAL;
+ }
+
if (rec->opts.record_switch_events &&
!perf_can_record_switch_events()) {
ui__error("kernel does not support recording context switch events\n");
--
2.17.2
next prev parent reply other threads:[~2019-03-10 15:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-10 15:30 [PATCHv6 0/5] perf record: Add support to store data in directory Jiri Olsa
2019-03-10 15:30 ` [PATCH 1/5] perf session: Add __perf_session__process_dir_events function Jiri Olsa
2019-03-10 15:30 ` [PATCH 2/5] perf session: Add path to reader object Jiri Olsa
2019-03-10 15:30 ` [PATCH 3/5] perf record: Add --dir option to store data in directory Jiri Olsa
2019-03-13 14:07 ` Namhyung Kim
2019-03-10 15:30 ` Jiri Olsa [this message]
2019-03-10 15:30 ` [PATCH 5/5] perf record: Describe perf.data directory format Jiri Olsa
2019-03-13 14:29 ` [PATCHv6 0/5] perf record: Add support to store data in directory Namhyung Kim
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=20190310153026.8661-5-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexey.budankov@linux.intel.com \
--cc=eranian@google.com \
--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).