From: Namhyung Kim <namhyung@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
linux-kernel@vger.kernel.org, jolsa@redhat.com,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v4 1/5] perf tools: Add 'perf-config' command
Date: Mon, 27 Jul 2015 16:59:12 +0900 [thread overview]
Message-ID: <20150727075912.GA22022@danjae.kornet> (raw)
In-Reply-To: <1437926311-16226-2-git-send-email-treeze.taeung@gmail.com>
Hi Taeung,
On Mon, Jul 27, 2015 at 12:58:27AM +0900, Taeung Song wrote:
> The perf configuration file contains many variables which can make
> the perf command's action more effective.
> But looking through state of configuration is difficult and there's no knowing
> what kind of other variables except variables in perfconfig.example exist.
> So This patch adds 'perf-config' command with '--list' option and a document for it.
>
> perf config [options]
>
> display current perf config variables.
> # perf config
> or
> # perf config -l | --list
>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
[SNIP]
> +kmem.*::
> + kmem.default::
> + This option can decide which allocator is analyzed between 'slab' and 'page'
> + without using options '--slab' and '--page'.
> + Default value is 'page'.
The default is 'slab'.
> +
> +SEE ALSO
> +--------
> +linkperf:perf[1], linkperf:perf-report[1]
> +
> +[kmem]
> + default = page
Ditto.
> diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
> new file mode 100644
> index 0000000..f0541b8
> --- /dev/null
> +++ b/tools/perf/builtin-config.c
> @@ -0,0 +1,76 @@
> +/*
> + * builtin-config.c
> + *
> + * Copyright (C) 2015, Taeung Song <treeze.taeung@gmail.com>
> + *
> + */
> +#include "builtin.h"
> +
> +#include "perf.h"
> +
> +#include "util/cache.h"
> +#include "util/parse-options.h"
> +#include "util/util.h"
> +#include "util/debug.h"
> +
> +static int actions;
> +
> +static const char * const config_usage[] = {
> + "perf config [options]",
> + NULL
> +};
> +
> +#define ACTION_LIST (1<<0)
> +
> +static const struct option config_options[] = {
> + OPT_GROUP("Action"),
> + OPT_BIT('l', "list", &actions,
> + "show current config variables", ACTION_LIST),
> + OPT_END()
> +};
> +
> +static int show_config(const char *key, const char *value,
> + void *cb __maybe_unused)
> +{
> + if (value)
> + printf("%s=%s\n", key, value);
> + else
> + printf("%s\n", key);
> +
> + return 0;
> +}
> +
> +int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
> +{
> + int ret = 0;
> + int origin_argc = argc - 1;
> + bool has_option;
Why are these needed?
> +
> + argc = parse_options(argc, argv, config_options, config_usage,
> + PARSE_OPT_STOP_AT_NON_OPTION);
> + if (origin_argc > argc)
> + has_option = true;
> + else
> + has_option = false;
> +
> + switch (actions) {
> + case ACTION_LIST:
> + if (argc == 0)
> + ret = perf_config(show_config, NULL);
> + else
> + goto out_err;
> + goto out;
> + default:
> + if (!has_option && argc == 0) {
> + ret = perf_config(show_config, NULL);
> + goto out;
> + } else
> + goto out_err;
> + }
Why not simply doing below instead?
case ACTION_LIST:
default:
if (argc)
error ...;
perf_config(show_config, ...);
break;
Thanks,
Namhyung
> +
> +out_err:
> + pr_err("Error: Unknown argument\n");
> + usage_with_options(config_usage, config_options);
> +out:
> + return ret;
> +}
next prev parent reply other threads:[~2015-07-27 8:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-26 15:58 [PATCH v4 0/5] perf tools: Add 'perf-config' command Taeung Song
2015-07-26 15:58 ` [PATCH v4 1/5] " Taeung Song
2015-07-27 7:59 ` Namhyung Kim [this message]
2015-07-26 15:58 ` [PATCH v4 2/5] perf config: Add '--system' and '--global' options to select which config file is used Taeung Song
2015-07-27 8:06 ` Namhyung Kim
2015-07-26 15:58 ` [PATCH v4 3/5] perf config: Add functions which can get or set perf config variables Taeung Song
2015-07-27 8:38 ` Namhyung Kim
2015-07-26 15:58 ` [PATCH v4 4/5] perf config: Add a option 'list-all' to perf-config Taeung Song
2015-07-27 8:48 ` Namhyung Kim
2015-08-07 1:12 ` taeung
2015-08-08 9:50 ` Taewoong Song
2015-08-09 3:07 ` Namhyung Kim
2015-08-09 3:01 ` Namhyung Kim
2015-08-09 7:54 ` Taewoong Song
2015-07-26 15:58 ` [PATCH v4 5/5] perf config: Add a option 'remove' " Taeung Song
-- strict thread matches above, loose matches on Subject: below --
2015-07-17 1:39 [PATCH v4 0/5] perf tools: Add 'perf-config' command Taeung Song
2015-07-17 1:39 ` [PATCH v4 1/5] " Taeung Song
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=20150727075912.GA22022@danjae.kornet \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=treeze.taeung@gmail.com \
/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