2017-03-17 05:57:19

by Du, Changbin

[permalink] [raw]
Subject: [PATCH] perf lock: subcommands should include common options

From: Changbin Du <[email protected]>

When I use -i option for report subcommand, it doesn't accept it.
We need add common options using OPT_PARENT macro.

perf lock report -i lock_perf.data
Error: unknown switch `i'

Usage: perf lock report [<options>]

-f, --force don't complain, do it
-k, --key <acquired> key for sorting ...

Signed-off-by: Changbin Du <[email protected]>
---
tools/perf/builtin-lock.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index ce3bfb4..710c551 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -947,27 +947,30 @@ static int __cmd_record(int argc, const char **argv)

int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
{
+ const struct option lock_options[] = {
+ OPT_STRING('i', "input", &input_name, "file", "input file name"),
+ OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
+ OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
+ OPT_END()
+ };
+
const struct option info_options[] = {
OPT_BOOLEAN('t', "threads", &info_threads,
"dump thread list in perf.data"),
OPT_BOOLEAN('m', "map", &info_map,
"map of lock instances (address:name table)"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
- OPT_END()
- };
- const struct option lock_options[] = {
- OPT_STRING('i', "input", &input_name, "file", "input file name"),
- OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
- OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
- OPT_END()
+ OPT_PARENT(lock_options)
};
+
const struct option report_options[] = {
OPT_STRING('k', "key", &sort_key, "acquired",
"key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
/* TODO: type */
- OPT_END()
+ OPT_PARENT(lock_options)
};
+
const char * const info_usage[] = {
"perf lock info [<options>]",
NULL
--
2.7.4


2017-03-17 14:10:01

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf lock: subcommands should include common options

Em Fri, Mar 17, 2017 at 01:53:42PM +0800, [email protected] escreveu:
> From: Changbin Du <[email protected]>
>
> When I use -i option for report subcommand, it doesn't accept it.
> We need add common options using OPT_PARENT macro.
>
> perf lock report -i lock_perf.data
> Error: unknown switch `i'
>
> Usage: perf lock report [<options>]
>
> -f, --force don't complain, do it
> -k, --key <acquired> key for sorting ...
>
> Signed-off-by: Changbin Du <[email protected]>
> ---
> tools/perf/builtin-lock.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> index ce3bfb4..710c551 100644
> --- a/tools/perf/builtin-lock.c
> +++ b/tools/perf/builtin-lock.c
> @@ -947,27 +947,30 @@ static int __cmd_record(int argc, const char **argv)
>
> int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
> {
> + const struct option lock_options[] = {
> + OPT_STRING('i', "input", &input_name, "file", "input file name"),
> + OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
> + OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
> + OPT_END()
> + };
> +
> const struct option info_options[] = {
> OPT_BOOLEAN('t', "threads", &info_threads,
> "dump thread list in perf.data"),
> OPT_BOOLEAN('m', "map", &info_map,
> "map of lock instances (address:name table)"),
> OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),

Good catch, OPT_PARENT came after 'perf lock', but you forgot 'f', I'm
adding it and renaming 'lock_options' to 'lock_input_options', ok?

> - OPT_END()
> - };
> - const struct option lock_options[] = {
> - OPT_STRING('i', "input", &input_name, "file", "input file name"),
> - OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
> - OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
> - OPT_END()
> + OPT_PARENT(lock_options)
> };
> +
> const struct option report_options[] = {
> OPT_STRING('k', "key", &sort_key, "acquired",
> "key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
> OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
> /* TODO: type */
> - OPT_END()
> + OPT_PARENT(lock_options)
> };
> +
> const char * const info_usage[] = {
> "perf lock info [<options>]",
> NULL
> --
> 2.7.4

2017-03-17 15:14:07

by Du, Changbin

[permalink] [raw]
Subject: Re: [PATCH] perf lock: subcommands should include common options

On Fri, Mar 17, 2017 at 11:08:34AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 17, 2017 at 01:53:42PM +0800, [email protected] escreveu:
> > From: Changbin Du <[email protected]>
> >
> > When I use -i option for report subcommand, it doesn't accept it.
> > We need add common options using OPT_PARENT macro.
> >
> > perf lock report -i lock_perf.data
> > Error: unknown switch `i'
> >
> > Usage: perf lock report [<options>]
> >
> > -f, --force don't complain, do it
> > -k, --key <acquired> key for sorting ...
> >
> > Signed-off-by: Changbin Du <[email protected]>
> > ---
> > tools/perf/builtin-lock.c | 19 +++++++++++--------
> > 1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> > index ce3bfb4..710c551 100644
> > --- a/tools/perf/builtin-lock.c
> > +++ b/tools/perf/builtin-lock.c
> > @@ -947,27 +947,30 @@ static int __cmd_record(int argc, const char **argv)
> >
> > int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
> > {
> > + const struct option lock_options[] = {
> > + OPT_STRING('i', "input", &input_name, "file", "input file name"),
> > + OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
> > + OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
> > + OPT_END()
> > + };
> > +
> > const struct option info_options[] = {
> > OPT_BOOLEAN('t', "threads", &info_threads,
> > "dump thread list in perf.data"),
> > OPT_BOOLEAN('m', "map", &info_map,
> > "map of lock instances (address:name table)"),
> > OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
>
> Good catch, OPT_PARENT came after 'perf lock', but you forgot 'f', I'm
> adding it and renaming 'lock_options' to 'lock_input_options', ok?
>
I am okay, just go ahead. thanks.

--
Thanks,
Changbin Du


Attachments:
(No filename) (1.87 kB)
signature.asc (473.00 B)
Download all attachments
Subject: [tip:perf/core] perf lock: Subcommands should include common options

Commit-ID: 249eed53152167c64c6dc66fa269a1d8b415a7b4
Gitweb: http://git.kernel.org/tip/249eed53152167c64c6dc66fa269a1d8b415a7b4
Author: Changbin Du <[email protected]>
AuthorDate: Fri, 17 Mar 2017 13:53:42 +0800
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 17 Mar 2017 11:49:07 -0300

perf lock: Subcommands should include common options

When I use -i option for report subcommand, it doesn't accept it. We
need add common options using OPT_PARENT macro.

perf lock report -i lock_perf.data
Error: unknown switch `i'

Usage: perf lock report [<options>]

-f, --force don't complain, do it
-k, --key <acquired> key for sorting ...

Signed-off-by: Changbin Du <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-lock.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index d750cca..4ce815b 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -948,27 +948,30 @@ static int __cmd_record(int argc, const char **argv)

int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
{
+ const struct option lock_options[] = {
+ OPT_STRING('i', "input", &input_name, "file", "input file name"),
+ OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
+ OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
+ OPT_END()
+ };
+
const struct option info_options[] = {
OPT_BOOLEAN('t', "threads", &info_threads,
"dump thread list in perf.data"),
OPT_BOOLEAN('m', "map", &info_map,
"map of lock instances (address:name table)"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
- OPT_END()
- };
- const struct option lock_options[] = {
- OPT_STRING('i', "input", &input_name, "file", "input file name"),
- OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"),
- OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"),
- OPT_END()
+ OPT_PARENT(lock_options)
};
+
const struct option report_options[] = {
OPT_STRING('k', "key", &sort_key, "acquired",
"key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
/* TODO: type */
- OPT_END()
+ OPT_PARENT(lock_options)
};
+
const char * const info_usage[] = {
"perf lock info [<options>]",
NULL