linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] perf kvm stat record: print kvm specific --help output
@ 2014-10-06 16:13 Alexander Yarygin
  2014-10-06 16:13 ` [PATCH] " Alexander Yarygin
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Yarygin @ 2014-10-06 16:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexander Yarygin, Arnaldo Carvalho de Melo,
	Christian Borntraeger, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra

Hello,

The 'perf kvm stat record' tool is an alias for 'perf record' tool.
When 'perf kvm stat record' is running with '--help' option, it prints
help output for 'perf record':


$ sudo perf kvm stat record --help
 usage: perf record [<options>] [<command>]
    or: perf record [<options>] -- <command> [<options>]

    -e, --event <event>   event selector. use 'perf list' to list available events
        --filter <filter>
                          event filter
    -p, --pid <pid>       record events on existing process id
    -t, --tid <tid>       record events on existing thread id
    -r, --realtime <n>    collect data with this RT SCHED_FIFO priority
    -D, --no-delay        collect data without buffering
    -R, --raw-samples     collect raw sample records from all opened counters
    -a, --all-cpus        system-wide collection from all CPUs
    -C, --cpu <cpu>       list of cpus to monitor
    -c, --count <n>       event period to sample
    -o, --output <file>   output file name
    .. snip ..


Some of these options can be used with 'kvm stat record', however others
can break recording (i.e. --no-samples), or don't change anything kvm related
(but they can add more details to the output file that are ignored by
'kvm stat report' and visible with 'perf report')

Plus the other 'perf kvm stat' tools have their own --help.

The patch is an proof-of-concept attempt to fix that inconsistency
by printing useful for 'perf kvm stat record' options in addition
to generic help. Like as follows:


$ sudo perf kvm stat record --help

 usage: perf kvm stat record [<options>]

    -p, --pid <pid>      record events on existing process id
    -t, --tid <tid>      record events on existing thread id
    -r, --realtime <n>   collect data with this RT SCHED_FIFO priority
        --no-buffering   collect data without buffering
    -a, --all-cpus       system-wide collection from all CPUs
    -C, --cpu <cpu>      list of cpus to monitor
    -c, --count <n>      event period to sample
    -o, --output <file>  output file name
    -i, --no-inherit     child tasks do not inherit counters
    -m, --mmap-pages <pages>
                         number of mmap data pages
    -v, --verbose        be more verbose (show counter open errors, etc)
    -q, --quiet          don't print any message
    -D, --delay <n>      ms to wait before starting measurement after program start
    -u, --uid <user>     user to profile
        --per-thread     use per-thread mmaps

Otherwise, it is the alias of 'perf record:'

 usage: perf record [<options>] [<command>]
    or: perf record [<options>] -- <command> [<options>]

    -e, --event <event>   event selector. use 'perf list' to list available events
        --filter <filter>
                          event filter
    -p, --pid <pid>       record events on existing process id
     .. here is the rest of the 'perf record' options ..


Problems:
1) I could drop some useful options.
2) Running 'perf kvm stat record' with invalid command leads to help message
  from 'perf record':


perf kvm stat record --i-want-help-from-record
  Error: unknown option `i-want-help-from-record'

 usage: perf record [<options>] [<command>]
    or: perf record [<options>] -- <command> [<options>]
    .. snip ..


Any ideas?

Thanks.


Alexander Yarygin (1):
  perf kvm stat record: print kvm specific --help output

 tools/perf/builtin-kvm.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] perf kvm stat record: print kvm specific --help output
  2014-10-06 16:13 [PATCH RFC] perf kvm stat record: print kvm specific --help output Alexander Yarygin
@ 2014-10-06 16:13 ` Alexander Yarygin
  2014-10-07 15:10   ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Yarygin @ 2014-10-06 16:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexander Yarygin, Arnaldo Carvalho de Melo,
	Christian Borntraeger, David Ahern, Ingo Molnar, Jiri Olsa,
	Paul Mackerras, Peter Zijlstra, Arnaldo Carvalho de Melo

The 'perf kvm stat record' tool is an alias of 'perf record' with
predefined kvm related options. All options that passed to 'perf kvm
stat record' are processed by the 'perf record' tool. So, 'perf kvm stat
record --help' prints  help of usage for the 'perf record'
command. There are a few options useful for 'perf kvm stat record', the
rest either break kvm related output or don't change it.

Let's print safe for 'perf kvm stat record' options in addition to
general 'perf record' --help output.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 tools/perf/builtin-kvm.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 43367eb..0c169d7 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1138,6 +1138,40 @@ exit:
 		_p;			\
 	})
 
+static void print_record_help(void)
+{
+	fprintf(stderr, "\n usage: perf kvm stat record [<options>]\n\n");
+
+	fprintf(stderr, "    -p, --pid <pid>      record events on existing process id\n");
+	fprintf(stderr, "    -t, --tid <tid>      record events on existing thread id\n");
+	fprintf(stderr, "    -r, --realtime <n>   collect data with this RT SCHED_FIFO priority\n");
+	fprintf(stderr, "        --no-buffering   collect data without buffering\n");
+	fprintf(stderr, "    -a, --all-cpus       system-wide collection from all CPUs\n");
+	fprintf(stderr, "    -C, --cpu <cpu>      list of cpus to monitor\n");
+	fprintf(stderr, "    -c, --count <n>      event period to sample\n");
+	fprintf(stderr, "    -o, --output <file>  output file name\n");
+	fprintf(stderr, "    -i, --no-inherit     child tasks do not inherit counters\n");
+	fprintf(stderr, "    -m, --mmap-pages <pages>\n");
+	fprintf(stderr, "                         number of mmap data pages\n");
+	fprintf(stderr, "    -v, --verbose        be more verbose (show counter open errors, etc)\n");
+	fprintf(stderr, "    -q, --quiet          don't print any message\n");
+	fprintf(stderr, "    -D, --delay <n>      ms to wait before starting measurement after program start\n");
+	fprintf(stderr, "    -u, --uid <user>     user to profile\n");
+	fprintf(stderr, "        --per-thread     use per-thread mmaps\n");
+
+	fprintf(stderr, "\nOtherwise, it is the alias of 'perf record:'\n");
+}
+
+static bool is_help_option(int argc, const char **argv)
+{
+	int i;
+
+	for (i = 0; i < argc; i++)
+		if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
+			return true;
+	return false;
+}
+
 static int
 kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
 {
@@ -1150,6 +1184,10 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
 		"-c", "1",
 	};
 	const char * const *events_tp;
+
+	if (argc == 1 || (argc > 1 && is_help_option(argc, argv)))
+		print_record_help();
+
 	events_tp_size = 0;
 
 	for (events_tp = kvm_events_tp; *events_tp; events_tp++)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf kvm stat record: print kvm specific --help output
  2014-10-06 16:13 ` [PATCH] " Alexander Yarygin
@ 2014-10-07 15:10   ` David Ahern
  2014-10-07 15:14     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2014-10-07 15:10 UTC (permalink / raw)
  To: Alexander Yarygin, linux-kernel
  Cc: Arnaldo Carvalho de Melo, Christian Borntraeger, Ingo Molnar,
	Jiri Olsa, Paul Mackerras, Peter Zijlstra,
	Arnaldo Carvalho de Melo

On 10/6/14, 10:13 AM, Alexander Yarygin wrote:

> +static void print_record_help(void)
> +{
> +	fprintf(stderr, "\n usage: perf kvm stat record [<options>]\n\n");
> +
> +	fprintf(stderr, "    -p, --pid <pid>      record events on existing process id\n");
> +	fprintf(stderr, "    -t, --tid <tid>      record events on existing thread id\n");
> +	fprintf(stderr, "    -r, --realtime <n>   collect data with this RT SCHED_FIFO priority\n");
> +	fprintf(stderr, "        --no-buffering   collect data without buffering\n");
> +	fprintf(stderr, "    -a, --all-cpus       system-wide collection from all CPUs\n");
> +	fprintf(stderr, "    -C, --cpu <cpu>      list of cpus to monitor\n");
> +	fprintf(stderr, "    -c, --count <n>      event period to sample\n");
> +	fprintf(stderr, "    -o, --output <file>  output file name\n");
> +	fprintf(stderr, "    -i, --no-inherit     child tasks do not inherit counters\n");
> +	fprintf(stderr, "    -m, --mmap-pages <pages>\n");
> +	fprintf(stderr, "                         number of mmap data pages\n");
> +	fprintf(stderr, "    -v, --verbose        be more verbose (show counter open errors, etc)\n");
> +	fprintf(stderr, "    -q, --quiet          don't print any message\n");
> +	fprintf(stderr, "    -D, --delay <n>      ms to wait before starting measurement after program start\n");
> +	fprintf(stderr, "    -u, --uid <user>     user to profile\n");
> +	fprintf(stderr, "        --per-thread     use per-thread mmaps\n");
> +
> +	fprintf(stderr, "\nOtherwise, it is the alias of 'perf record:'\n");
> +}

Those are all perf-record options, not perf-kvm-stat-record options. 
This usage should not repeat perf-record.

David


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf kvm stat record: print kvm specific --help output
  2014-10-07 15:10   ` David Ahern
@ 2014-10-07 15:14     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-10-07 15:14 UTC (permalink / raw)
  To: David Ahern
  Cc: Alexander Yarygin, linux-kernel, Christian Borntraeger,
	Ingo Molnar, Jiri Olsa, Paul Mackerras, Peter Zijlstra

Em Tue, Oct 07, 2014 at 09:10:46AM -0600, David Ahern escreveu:
> On 10/6/14, 10:13 AM, Alexander Yarygin wrote:
> 
> >+static void print_record_help(void)
> >+{
> >+	fprintf(stderr, "\n usage: perf kvm stat record [<options>]\n\n");
> >+
> >+	fprintf(stderr, "    -p, --pid <pid>      record events on existing process id\n");
> >+	fprintf(stderr, "    -t, --tid <tid>      record events on existing thread id\n");
> >+	fprintf(stderr, "    -r, --realtime <n>   collect data with this RT SCHED_FIFO priority\n");
> >+	fprintf(stderr, "        --no-buffering   collect data without buffering\n");
> >+	fprintf(stderr, "    -a, --all-cpus       system-wide collection from all CPUs\n");
> >+	fprintf(stderr, "    -C, --cpu <cpu>      list of cpus to monitor\n");
> >+	fprintf(stderr, "    -c, --count <n>      event period to sample\n");
> >+	fprintf(stderr, "    -o, --output <file>  output file name\n");
> >+	fprintf(stderr, "    -i, --no-inherit     child tasks do not inherit counters\n");
> >+	fprintf(stderr, "    -m, --mmap-pages <pages>\n");
> >+	fprintf(stderr, "                         number of mmap data pages\n");
> >+	fprintf(stderr, "    -v, --verbose        be more verbose (show counter open errors, etc)\n");
> >+	fprintf(stderr, "    -q, --quiet          don't print any message\n");
> >+	fprintf(stderr, "    -D, --delay <n>      ms to wait before starting measurement after program start\n");
> >+	fprintf(stderr, "    -u, --uid <user>     user to profile\n");
> >+	fprintf(stderr, "        --per-thread     use per-thread mmaps\n");
> >+
> >+	fprintf(stderr, "\nOtherwise, it is the alias of 'perf record:'\n");
> >+}
> 
> Those are all perf-record options, not perf-kvm-stat-record options. This
> usage should not repeat perf-record.

Right, and from a quick look, the way Namhyung is tackling this problem
is better.

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-07 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 16:13 [PATCH RFC] perf kvm stat record: print kvm specific --help output Alexander Yarygin
2014-10-06 16:13 ` [PATCH] " Alexander Yarygin
2014-10-07 15:10   ` David Ahern
2014-10-07 15:14     ` Arnaldo Carvalho de Melo

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).