linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: kan.liang@intel.com
Cc: acme@kernel.org, jolsa@kernel.org, namhyung@kernel.org,
	ak@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC V3 1/5] perf,tools: introduce OPT_CALLBACK_SET/OPT_CALLBACK_NOOPT_SET
Date: Tue, 14 Jul 2015 08:54:48 +0200	[thread overview]
Message-ID: <20150714065448.GF22977@krava.local> (raw)
In-Reply-To: <1436345097-11113-2-git-send-email-kan.liang@intel.com>

On Wed, Jul 08, 2015 at 04:44:53AM -0400, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> This patch extends the OPT_CALLBACK/OPT_CALLBACK_NOOPT to support 'set'
> item of struct option. So the perf knows whether an option was set by
> user.
> The new macros are used by call-graph options.
> 
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
>  tools/perf/builtin-record.c     | 4 ++--
>  tools/perf/perf.h               | 1 +
>  tools/perf/util/parse-options.c | 2 ++
>  tools/perf/util/parse-options.h | 4 ++++
>  4 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 283fe96..a6eb24e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1018,10 +1018,10 @@ struct option __record_options[] = {
>  		     record__parse_mmap_pages),
>  	OPT_BOOLEAN(0, "group", &record.opts.group,
>  		    "put the counters into a counter group"),
> -	OPT_CALLBACK_NOOPT('g', NULL, &record.opts,
> +	OPT_CALLBACK_NOOPT_SET('g', NULL, &record.opts, &record.opts.callgraph_set,
>  			   NULL, "enables call-graph recording" ,
>  			   &record_callchain_opt),
> -	OPT_CALLBACK(0, "call-graph", &record.opts,
> +	OPT_CALLBACK_SET(0, "call-graph", &record.opts, &record.opts.callgraph_set,
>  		     "mode[,dump_size]", record_callchain_help,
>  		     &record_parse_callchain_opt),

we already provide &record.opts and callback which can set
record.opts.callgraph_set.. seems redundant do I miss some
other benefit?

jirka

>  	OPT_INCR('v', "verbose", &verbose,
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 937b16a..9ba02e0 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -52,6 +52,7 @@ struct record_opts {
>  	bool	     sample_weight;
>  	bool	     sample_time;
>  	bool	     sample_time_set;
> +	bool	     callgraph_set;
>  	bool	     period;
>  	bool	     sample_intr_regs;
>  	bool	     running_time;
> diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
> index 01626be..064385f 100644
> --- a/tools/perf/util/parse-options.c
> +++ b/tools/perf/util/parse-options.c
> @@ -140,6 +140,8 @@ static int get_value(struct parse_opt_ctx_t *p,
>  		return err;
>  
>  	case OPTION_CALLBACK:
> +		if (opt->set)
> +			*(bool *)opt->set = true;
>  		if (unset)
>  			return (*opt->callback)(opt, NULL, 1) ? (-1) : 0;
>  		if (opt->flags & PARSE_OPT_NOARG)
> diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
> index 367d8b8..2bec32e 100644
> --- a/tools/perf/util/parse-options.h
> +++ b/tools/perf/util/parse-options.h
> @@ -132,8 +132,12 @@ struct option {
>  	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
>  #define OPT_CALLBACK(s, l, v, a, h, f) \
>  	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f) }
> +#define OPT_CALLBACK_SET(s, l, v, os, a, h, f) \
> +	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .set = check_vtype(os, bool *) }
>  #define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
>  	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
> +#define OPT_CALLBACK_NOOPT_SET(s, l, v, os, a, h, f) \
> +	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG, .set = check_vtype(os, bool *) }
>  #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
>  	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = PARSE_OPT_LASTARG_DEFAULT }
>  #define OPT_CALLBACK_DEFAULT_NOOPT(s, l, v, a, h, f, d) \
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2015-07-14  6:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  8:44 [PATCH RFC V3 0/5] partial callgrap and time support kan.liang
2015-07-08  8:44 ` [PATCH RFC V3 1/5] perf,tools: introduce OPT_CALLBACK_SET/OPT_CALLBACK_NOOPT_SET kan.liang
2015-07-14  6:54   ` Jiri Olsa [this message]
2015-07-08  8:44 ` [PATCH RFC V3 2/5] perf/documentation: Add description for period kan.liang
2015-07-14  6:55   ` Jiri Olsa
2015-07-14 14:05     ` Arnaldo Carvalho de Melo
2015-07-21  9:31   ` [tip:perf/core] perf record: Document setting '-e pmu/period=N/' in man page tip-bot for Kan Liang
2015-07-08  8:44 ` [PATCH RFC V3 3/5] perf,tool: partial time support kan.liang
2015-07-13 13:27   ` Namhyung Kim
2015-07-13 19:01     ` Liang, Kan
2015-07-14  1:04       ` Namhyung Kim
2015-07-15 19:03         ` Liang, Kan
2015-07-17  7:12           ` Namhyung Kim
2015-07-14  6:54   ` Jiri Olsa
2015-07-14  6:54   ` Jiri Olsa
2015-07-08  8:44 ` [PATCH RFC V3 4/5] perf,tool: partial callgrap support kan.liang
2015-07-08  8:44 ` [PATCH RFC V3 5/5] perf,tests: Add tests to callgrap and time parse kan.liang

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=20150714065448.GF22977@krava.local \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.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).