Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1549602 > unrolled thread
| Started by | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| First post | 2017-01-03 09:30 +0100 |
| Last post | 2017-01-10 19:50 +0100 |
| Articles | 9 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[PATCH 1/7] tools lib subcmd: Add OPT_STRING_OPTARG_SET option Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[tip:perf/urgent] tools lib subcmd: Add OPT_STRING_OPTARG_SET option tip-bot for Jiri Olsa <tipbot@zytor.com> - 2017-01-05 09:00 +0100
[PATCH 4/7] perf record: Add struct switch_output Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[PATCH 5/7] perf record: Change switch-output option to take optional argument Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-03 11:00 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@redhat.com> - 2017-01-03 11:40 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-10 14:40 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@redhat.com> - 2017-01-10 19:50 +0100
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2017-01-03 09:30 +0100 |
| Subject | [PATCH 0/7] perf tools: Add switch-output size and time threshold options |
| Message-ID | <sVsDM-3nL-5@gated-at.bofh.it> |
hi,
adding a way to configure switch data output
for size and time, like:
$ sudo perf record -e 'sched:*' --switch-output=10M -avg
callchain: type FP
switch-output with 10M size threshold
mmap size 528384B
[ perf record: dump data: Woken up 37 times ]
[ perf record: Dump perf.data.2017010309135512 ]
[ perf record: dump data: Woken up 39 times ]
[ perf record: Dump perf.data.2017010309135771 ]
[ perf record: dump data: Woken up 38 times ]
[ perf record: Dump perf.data.2017010309140005 ]
^C[ perf record: Woken up 16 times to write data ]
[ perf record: Dump perf.data.2017010309140111 ]
[ perf record: Captured and wrote 4.748 MB perf.data.<timestamp> ]
...
the default for switch-output option stays
and does the SIGUSR2 output switch
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
Cc: Wang Nan <wangnan0@huawei.com>
---
Jiri Olsa (7):
tools lib subcmd: Add OPT_STRING_OPTARG_SET option
perf record: Make __record_options static
perf record: Fix --switch-output documentation and comment
perf record: Add struct switch_output
perf record: Change switch-output option to take optional argument
perf record: Add switch-output size option argument
perf record: Add switch-output time option argument
tools/lib/subcmd/parse-options.c | 3 ++
tools/lib/subcmd/parse-options.h | 5 ++++
tools/perf/Documentation/perf-record.txt | 13 +++++++--
tools/perf/builtin-record.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
4 files changed, 139 insertions(+), 16 deletions(-)
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2017-01-03 09:30 +0100 |
| Subject | [PATCH 1/7] tools lib subcmd: Add OPT_STRING_OPTARG_SET option |
| Message-ID | <sVsDM-3nL-19@gated-at.bofh.it> |
| In reply to | #1549602 |
To allow string options with default argument and
variable set when the option is used.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: http://lkml.kernel.org/n/tip-xqtj0dy6t4bzah3jqi20tz43@git.kernel.org
---
tools/lib/subcmd/parse-options.c | 3 +++
tools/lib/subcmd/parse-options.h | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 3284bb14ae78..8aad81151d50 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -213,6 +213,9 @@ static int get_value(struct parse_opt_ctx_t *p,
else
err = get_arg(p, opt, flags, (const char **)opt->value);
+ if (opt->set)
+ *(bool *)opt->set = true;
+
/* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */
if (opt->flags & PARSE_OPT_NOEMPTY) {
const char *val = *(const char **)opt->value;
diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 8866ac438b34..11c3be3bcce7 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -137,6 +137,11 @@ struct option {
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
.value = check_vtype(v, const char **), (a), .help = (h), \
.flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
+#define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
+ { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
+ .value = check_vtype(v, const char **), (a), .help = (h), \
+ .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
+ .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 **), (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 }
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2017-01-05 09:00 +0100 |
| Subject | [tip:perf/urgent] tools lib subcmd: Add OPT_STRING_OPTARG_SET option |
| Message-ID | <sWb7R-8fR-51@gated-at.bofh.it> |
| In reply to | #1549604 |
Commit-ID: b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4
Gitweb: http://git.kernel.org/tip/b66fb1da5a8cac3f5c3cdbe41937c91efc4e76a4
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 3 Jan 2017 09:19:54 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 3 Jan 2017 11:10:38 -0300
tools lib subcmd: Add OPT_STRING_OPTARG_SET option
To allow string options with a default argument and variable set when
the option is used.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1483431600-19887-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/subcmd/parse-options.c | 3 +++
tools/lib/subcmd/parse-options.h | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 3284bb1..8aad811 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -213,6 +213,9 @@ static int get_value(struct parse_opt_ctx_t *p,
else
err = get_arg(p, opt, flags, (const char **)opt->value);
+ if (opt->set)
+ *(bool *)opt->set = true;
+
/* PARSE_OPT_NOEMPTY: Allow NULL but disallow empty string. */
if (opt->flags & PARSE_OPT_NOEMPTY) {
const char *val = *(const char **)opt->value;
diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 8866ac4..11c3be3 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -137,6 +137,11 @@ struct option {
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
.value = check_vtype(v, const char **), (a), .help = (h), \
.flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
+#define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
+ { .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
+ .value = check_vtype(v, const char **), (a), .help = (h), \
+ .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
+ .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 **), (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 }
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2017-01-03 09:30 +0100 |
| Subject | [PATCH 4/7] perf record: Add struct switch_output |
| Message-ID | <sVsDM-3nL-25@gated-at.bofh.it> |
| In reply to | #1549602 |
Next patches will add more --switch-output option arguments,
so preparing the data holder.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-tibmeq1qw3kgrfzrswt5xypx@git.kernel.org
---
tools/perf/builtin-record.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 4ec10e9427d9..f7e805b30527 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -46,6 +46,10 @@
#include <asm/bug.h>
#include <linux/time64.h>
+struct switch_output {
+ bool signal;
+};
+
struct record {
struct perf_tool tool;
struct record_opts opts;
@@ -62,7 +66,7 @@ struct record {
bool no_buildid_cache_set;
bool buildid_all;
bool timestamp_filename;
- bool switch_output;
+ struct switch_output switch_output;
unsigned long long samples;
};
@@ -842,11 +846,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
signal(SIGTERM, sig_handler);
signal(SIGSEGV, sigsegv_handler);
- if (rec->opts.auxtrace_snapshot_mode || rec->switch_output) {
+ if (rec->opts.auxtrace_snapshot_mode || rec->switch_output.signal) {
signal(SIGUSR2, snapshot_sig_handler);
if (rec->opts.auxtrace_snapshot_mode)
trigger_on(&auxtrace_snapshot_trigger);
- if (rec->switch_output)
+ if (rec->switch_output.signal)
trigger_on(&switch_output_trigger);
} else {
signal(SIGUSR2, SIG_IGN);
@@ -1519,7 +1523,7 @@ static struct option __record_options[] = {
"Record build-id of all DSOs regardless of hits"),
OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
"append timestamp to output filename"),
- OPT_BOOLEAN(0, "switch-output", &record.switch_output,
+ OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal,
"Switch output when receive SIGUSR2"),
OPT_BOOLEAN(0, "dry-run", &dry_run,
"Parse options then exit"),
@@ -1578,7 +1582,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
return -EINVAL;
}
- if (rec->switch_output)
+ if (rec->switch_output.signal)
rec->timestamp_filename = true;
if (!rec->itr) {
@@ -1629,7 +1633,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
if (rec->no_buildid_cache || rec->no_buildid) {
disable_buildid_cache();
- } else if (rec->switch_output) {
+ } else if (rec->switch_output.signal) {
/*
* In 'perf record --switch-output', disable buildid
* generation by default to reduce data file switching
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2017-01-03 09:30 +0100 |
| Subject | [PATCH 5/7] perf record: Change switch-output option to take optional argument |
| Message-ID | <sVsDM-3nL-33@gated-at.bofh.it> |
| In reply to | #1549602 |
Next patches will add --switch-output option arguments,
changing the option to allow that and adding its default
value to 'signal'.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-d3qy0tnc4m2dyt8yd6x5phyv@git.kernel.org
---
tools/perf/builtin-record.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f7e805b30527..b503e5ebc1e7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -48,6 +48,8 @@
struct switch_output {
bool signal;
+ const char *str;
+ bool set;
};
struct record {
@@ -1356,6 +1358,17 @@ static int record__parse_mmap_pages(const struct option *opt,
return ret;
}
+static int switch_output_setup(struct switch_output *s)
+{
+ if (!strcmp(s->str, "signal")) {
+ s->signal = true;
+ pr_debug("switch-output with SIGUSR2 signal\n");
+ return 0;
+ }
+
+ return -1;
+}
+
static const char * const __record_usage[] = {
"perf record [<options>] [<command>]",
"perf record [<options>] -- <command> [<options>]",
@@ -1523,8 +1536,9 @@ static struct option __record_options[] = {
"Record build-id of all DSOs regardless of hits"),
OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
"append timestamp to output filename"),
- OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal,
- "Switch output when receive SIGUSR2"),
+ OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str,
+ &record.switch_output.set, "signal",
+ "Switch output when receive SIGUSR2", "signal"),
OPT_BOOLEAN(0, "dry-run", &dry_run,
"Parse options then exit"),
OPT_END()
@@ -1582,6 +1596,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
return -EINVAL;
}
+ if (record.switch_output.set &&
+ switch_output_setup(&rec->switch_output)) {
+ parse_options_usage(record_usage, record_options, "switch-output", 0);
+ return -EINVAL;
+ }
+
if (rec->switch_output.signal)
rec->timestamp_filename = true;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2017-01-03 11:00 +0100 |
| Subject | Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options |
| Message-ID | <sVu2R-4qr-5@gated-at.bofh.it> |
| In reply to | #1549602 |
On 2017/1/3 16:19, Jiri Olsa wrote: > hi, > adding a way to configure switch data output > for size and time, like: > > $ sudo perf record -e 'sched:*' --switch-output=10M -avg > callchain: type FP > switch-output with 10M size threshold > mmap size 528384B > [ perf record: dump data: Woken up 37 times ] > [ perf record: Dump perf.data.2017010309135512 ] > [ perf record: dump data: Woken up 39 times ] > [ perf record: Dump perf.data.2017010309135771 ] > [ perf record: dump data: Woken up 38 times ] > [ perf record: Dump perf.data.2017010309140005 ] > ^C[ perf record: Woken up 16 times to write data ] > [ perf record: Dump perf.data.2017010309140111 ] > [ perf record: Captured and wrote 4.748 MB perf.data.<timestamp> ] > ... > > the default for switch-output option stays > and does the SIGUSR2 output switch > > Also available in: > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git > perf/fixes > > thanks, > jirka > > > Cc: Wang Nan <wangnan0@huawei.com> > --- Good functions, and thank you for fixing documentations. You didn't cc patch 1 and 2 to me. Tested-by: Wang Nan <wangnan0@huawei.com> > Jiri Olsa (7): > tools lib subcmd: Add OPT_STRING_OPTARG_SET option > perf record: Make __record_options static > perf record: Fix --switch-output documentation and comment > perf record: Add struct switch_output > perf record: Change switch-output option to take optional argument > perf record: Add switch-output size option argument > perf record: Add switch-output time option argument > > tools/lib/subcmd/parse-options.c | 3 ++ > tools/lib/subcmd/parse-options.h | 5 ++++ > tools/perf/Documentation/perf-record.txt | 13 +++++++-- > tools/perf/builtin-record.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- > 4 files changed, 139 insertions(+), 16 deletions(-)
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2017-01-03 11:40 +0100 |
| Subject | Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options |
| Message-ID | <sVuFz-4UG-13@gated-at.bofh.it> |
| In reply to | #1549655 |
On Tue, Jan 03, 2017 at 05:51:46PM +0800, Wangnan (F) wrote: > > > On 2017/1/3 16:19, Jiri Olsa wrote: > > hi, > > adding a way to configure switch data output > > for size and time, like: > > > > $ sudo perf record -e 'sched:*' --switch-output=10M -avg > > callchain: type FP > > switch-output with 10M size threshold > > mmap size 528384B > > [ perf record: dump data: Woken up 37 times ] > > [ perf record: Dump perf.data.2017010309135512 ] > > [ perf record: dump data: Woken up 39 times ] > > [ perf record: Dump perf.data.2017010309135771 ] > > [ perf record: dump data: Woken up 38 times ] > > [ perf record: Dump perf.data.2017010309140005 ] > > ^C[ perf record: Woken up 16 times to write data ] > > [ perf record: Dump perf.data.2017010309140111 ] > > [ perf record: Captured and wrote 4.748 MB perf.data.<timestamp> ] > > ... > > > > the default for switch-output option stays > > and does the SIGUSR2 output switch > > > > Also available in: > > git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git > > perf/fixes > > > > thanks, > > jirka > > > > > > Cc: Wang Nan <wangnan0@huawei.com> > > --- > > Good functions, and thank you for fixing documentations. > > You didn't cc patch 1 and 2 to me. sry, will do next time.. thanks ;-) jirka
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-01-10 14:40 +0100 |
| Subject | Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options |
| Message-ID | <sY4OC-1Tf-51@gated-at.bofh.it> |
| In reply to | #1549655 |
Em Tue, Jan 03, 2017 at 05:51:46PM +0800, Wangnan (F) escreveu: > On 2017/1/3 16:19, Jiri Olsa wrote: > > Cc: Wang Nan <wangnan0@huawei.com> > > --- > > Good functions, and thank you for fixing documentations. > > You didn't cc patch 1 and 2 to me. > Tested-by: Wang Nan <wangnan0@huawei.com> I'm tentatively switching this to an Acked-by for the latest version from Jiri, that should have no major changes, right? - Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2017-01-10 19:50 +0100 |
| Subject | Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options |
| Message-ID | <sY9EC-4Q2-19@gated-at.bofh.it> |
| In reply to | #1555270 |
On Tue, Jan 10, 2017 at 10:35:57AM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Jan 03, 2017 at 05:51:46PM +0800, Wangnan (F) escreveu: > > On 2017/1/3 16:19, Jiri Olsa wrote: > > > Cc: Wang Nan <wangnan0@huawei.com> > > > --- > > > > Good functions, and thank you for fixing documentations. > > > > You didn't cc patch 1 and 2 to me. > > > Tested-by: Wang Nan <wangnan0@huawei.com> > > I'm tentatively switching this to an Acked-by for the latest version > from Jiri, that should have no major changes, right? well, not major.. but some for sure ;-) jirka
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web