mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] perf tool: save cmdline from user in file header vs what is passed to record
Date: Fri, 6 Jul 2012 14:17:35 -0300	[thread overview]
Message-ID: <20120706171735.GH7533@infradead.org> (raw)
In-Reply-To: <1341547762-17430-1-git-send-email-dsahern@gmail.com>

Em Thu, Jul 05, 2012 at 10:09:22PM -0600, David Ahern escreveu:
> A number of builtin commands process some user args and then pass the rest
> to cmd_record. cmd_record then saves argc/argv that it receives into the
> header of the perf data file. But this loses the arguments handled by the
> first command -- ie., the real command line from the user. This patch saves
> the command line as typed by the user rather than what was passed to
> cmd_record.

Can you please state for what branch, perf/urgent (i.e. current merge
window) or perf/core (next), this is intended? I usually have been
making the call, but having feedback from the submitter can help things
and help meet expectations more frequently.

I'd say this one should be for perf/core, as it is not so critical, what
do you think?

- Arnaldo
 
> As an example consider the command:
> $ perf kvm --guest --host --guestmount=/tmp/guest-mount record
>     -fo /tmp/perf.data -ag -- sleep 10
> 
> Currently the command saved to the header is:
> cmdline : /tmp/p3.5/perf record -o perf.data.kvm -fo /tmp/perf.data -ag -- sleep 1
> 
> (ignore the duplicated -o -- the first would be yet another bug with perf-kvm).
> 
> With this patch the command line saved to the header is:
> cmdline : /tmp/p3.5/perf kvm --guest --host --guestmount=/tmp/guest-mount
>     record -fo /tmp/perf.data -ag -- sleep 1
> 
> v2: simplified to saving the command in parse_options per Stephane's suggestion
> 
> Signed-off-by: David Ahern <dsahern@gmail.com>
> CC: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@gmail.com>
> Cc: Stephane Eranian <eranian@google.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
>  tools/perf/builtin-record.c     |    2 --
>  tools/perf/util/header.c        |    9 +++++++++
>  tools/perf/util/parse-options.c |    3 +++
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index f5a6452..77adcd8 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -844,8 +844,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
>  	struct perf_record *rec = &record;
>  	char errbuf[BUFSIZ];
>  
> -	perf_header__set_cmdline(argc, argv);
> -
>  	evsel_list = perf_evlist__new(NULL, NULL);
>  	if (evsel_list == NULL)
>  		return -ENOMEM;
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 5a47aba..99e410c 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -174,6 +174,15 @@ perf_header__set_cmdline(int argc, const char **argv)
>  {
>  	int i;
>  
> +	/* 
> +	 * If header_argv has already been set, do not override it.
> +	 * This allows a command to set the cmdline, parse args and
> +	 * then call another builtin function that implements a
> +	 * command -- e.g, cmd_kvm calling cmd_record.
> +	 */
> +	if (header_argv)
> +		return 0;
> +
>  	header_argc = (u32)argc;
>  
>  	/* do not include NULL termination */
> diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
> index 99d02aa..594f8fa 100644
> --- a/tools/perf/util/parse-options.c
> +++ b/tools/perf/util/parse-options.c
> @@ -1,6 +1,7 @@
>  #include "util.h"
>  #include "parse-options.h"
>  #include "cache.h"
> +#include "header.h"
>  
>  #define OPT_SHORT 1
>  #define OPT_UNSET 2
> @@ -413,6 +414,8 @@ int parse_options(int argc, const char **argv, const struct option *options,
>  {
>  	struct parse_opt_ctx_t ctx;
>  
> +	perf_header__set_cmdline(argc, argv);
> +
>  	parse_options_start(&ctx, argc, argv, flags);
>  	switch (parse_options_step(&ctx, options, usagestr)) {
>  	case PARSE_OPT_HELP:
> -- 
> 1.7.10.1

  reply	other threads:[~2012-07-06 17:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06  4:09 David Ahern
2012-07-06 17:17 ` Arnaldo Carvalho de Melo [this message]
2012-07-06 17:19   ` David Ahern
  -- strict thread matches above, loose matches on Subject: below --
2012-07-30  2:53 David Ahern
2012-07-03  4:08 David Ahern
2012-07-05 15:48 ` Stephane Eranian
2012-07-05 16:47   ` David Ahern

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=20120706171735.GH7533@infradead.org \
    --to=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®