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, Ingo Molnar <mingo@redhat.com>,
Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH v11 16/24] perf config: Add '--system' and '--user' options to select which config file is used
Date: Wed, 18 Nov 2015 14:11:10 +0900 [thread overview]
Message-ID: <20151118051110.GO7062@sejong> (raw)
In-Reply-To: <1447768424-17327-16-git-send-email-treeze.taeung@gmail.com>
On Tue, Nov 17, 2015 at 10:53:36PM +0900, Taeung Song wrote:
> The file-options '--system' means $(sysconfdir)/perfconfig and
> '--user' means $HOME/.perfconfig. If file-option isn't used,
> both system and user config file is read.
> The syntax examples are like below.
>
> perf config [<file-option>] [options]
>
> a specific config file.
> # perf config --user | --system
> or
> both user and system config file.
> # perf config
>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> ---
> tools/perf/Documentation/perf-config.txt | 14 +++++++++++++-
> tools/perf/builtin-config.c | 18 +++++++++++++++++-
> tools/perf/util/cache.h | 3 +++
> tools/perf/util/config.c | 4 ++--
> 4 files changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
> index 95255a0..f556672 100644
> --- a/tools/perf/Documentation/perf-config.txt
> +++ b/tools/perf/Documentation/perf-config.txt
> @@ -8,7 +8,7 @@ perf-config - Get and set variables in a configuration file.
> SYNOPSIS
> --------
> [verse]
> -'perf config' -l | --list
> +'perf config' [<file-option>] -l | --list
>
> DESCRIPTION
> -----------
> @@ -21,6 +21,14 @@ OPTIONS
> --list::
> Show current config variables, name and value, for all sections.
>
> +--user::
> + For writing and reading options: write to user
> + '$HOME/.perfconfig' file or read it.
> +
> +--system::
> + For writing and reading options: write to system-wide
> + '$(sysconfdir)/perfconfig' or read it.
> +
> CONFIGURATION FILE
> ------------------
>
> @@ -30,6 +38,10 @@ The '$HOME/.perfconfig' file is used to store a per-user configuration.
> The file '$(sysconfdir)/perfconfig' can be used to
> store a system-wide default configuration.
>
> +When reading or writing, the values are read from the system and user
> +configuration files by default, and options '--system' and '--user'
> +can be used to tell the command to read from or write to only that location.
> +
> Syntax
> ~~~~~~
>
> diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
> index 427ea7a..e0f8b41 100644
> --- a/tools/perf/builtin-config.c
> +++ b/tools/perf/builtin-config.c
> @@ -13,8 +13,10 @@
> #include "util/util.h"
> #include "util/debug.h"
>
> +static bool use_system_config, use_user_config;
> +
> static const char * const config_usage[] = {
> - "perf config [options]",
> + "perf config [<file-option>] [options]",
> NULL
> };
>
> @@ -25,6 +27,8 @@ enum actions {
> static struct option config_options[] = {
> OPT_SET_UINT('l', "list", &actions,
> "show current config variables", ACTION_LIST),
> + OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
> + OPT_BOOLEAN(0, "user", &use_user_config, "use user config file"),
> OPT_END()
> };
>
> @@ -46,6 +50,18 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
> argc = parse_options(argc, argv, config_options, config_usage,
> PARSE_OPT_STOP_AT_NON_OPTION);
>
> + if (use_system_config && use_user_config) {
> + pr_err("Error: only one config file at a time\n");
> + parse_options_usage(config_usage, config_options, "user", 0);
> + parse_options_usage(NULL, config_options, "system", 0);
> + return -1;
> + }
> +
> + if (use_system_config)
> + config_exclusive_filename = perf_etc_perfconfig();
> + else if (use_user_config)
> + config_exclusive_filename = mkpath("%s/.perfconfig", getenv("HOME"));
> +
> switch (actions) {
> case ACTION_LIST:
> if (argc) {
> diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
> index c861373..d1eb75f 100644
> --- a/tools/perf/util/cache.h
> +++ b/tools/perf/util/cache.h
> @@ -19,6 +19,8 @@
> #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
> #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
>
> +extern const char *config_exclusive_filename;
> +
> typedef int (*config_fn_t)(const char *, const char *, void *);
> extern int perf_default_config(const char *, const char *, void *);
> extern int perf_config(config_fn_t fn, void *);
> @@ -27,6 +29,7 @@ extern u64 perf_config_u64(const char *, const char *);
> extern int perf_config_bool(const char *, const char *);
> extern int config_error_nonbool(const char *);
> extern const char *perf_config_dirname(const char *, const char *);
> +extern const char *perf_etc_perfconfig(void);
>
> /* pager.c */
> extern void setup_pager(void);
> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
> index 2e452ac..55ef373 100644
> --- a/tools/perf/util/config.c
> +++ b/tools/perf/util/config.c
> @@ -26,7 +26,7 @@ static const char *config_file_name;
> static int config_linenr;
> static int config_file_eof;
>
> -static const char *config_exclusive_filename;
> +const char *config_exclusive_filename;
>
> static int get_next_char(void)
> {
> @@ -434,7 +434,7 @@ static int perf_config_from_file(config_fn_t fn, const char *filename, void *dat
> return ret;
> }
>
> -static const char *perf_etc_perfconfig(void)
> +const char *perf_etc_perfconfig(void)
> {
> static const char *system_wide;
> if (!system_wide)
> --
> 1.9.1
>
next prev parent reply other threads:[~2015-11-18 5:11 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 13:53 [PATCH v11 01/24] perf tools: Add 'perf-config' command Taeung Song
2015-11-17 13:53 ` [PATCH v11 02/24] perf tools: Add perf-config document Taeung Song
2015-11-17 23:13 ` Namhyung Kim
2015-11-19 19:24 ` Arnaldo Carvalho de Melo
2015-11-22 10:07 ` Taeung Song
2015-11-22 10:11 ` [PATCH v11 RESEND " Taeung Song
2015-11-23 14:17 ` Arnaldo Carvalho de Melo
2015-11-26 8:20 ` [tip:perf/core] perf config: Add initial man page tip-bot for Taeung Song
2015-11-17 13:53 ` [PATCH v11 03/24] perf config: Document variables for 'color' section in " Taeung Song
2015-11-17 23:47 ` Namhyung Kim
2015-12-01 3:59 ` Taeung Song
2015-11-17 13:53 ` [PATCH v11 04/24] perf config: Document variables for 'tui' and 'gtk' sections " Taeung Song
2015-11-18 0:01 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 05/24] perf config: Document 'buildid.dir' variable " Taeung Song
2015-11-18 0:03 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 06/24] perf config: Document variables for 'annotate' section " Taeung Song
2015-11-18 0:24 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 07/24] perf config: Document variables for 'help' " Taeung Song
2015-11-18 0:45 ` Namhyung Kim
2015-12-01 16:17 ` Taeung Song
2015-11-17 13:53 ` [PATCH v11 08/24] perf config: Document 'hist.percentage' variable " Taeung Song
2015-11-18 0:49 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 09/24] perf config: Document 'ui.show-headers' " Taeung Song
2015-11-18 0:59 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 10/24] perf config: Document variables for 'call-graph' section " Taeung Song
2015-11-18 2:51 ` Namhyung Kim
2015-11-30 1:42 ` Taeung Song
2015-11-30 5:03 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 11/24] perf config: Document variables for 'report' " Taeung Song
2015-11-18 3:01 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 12/24] perf config: Document 'top.chidren' variable " Taeung Song
2015-11-18 3:04 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 13/24] perf config: Document 'man.viewer' " Taeung Song
2015-11-18 4:58 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 14/24] perf config: Document 'pager.<subcommand>' variables " Taeung Song
2015-11-18 5:05 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 15/24] perf config: Document 'kmem.default' variable " Taeung Song
2015-11-18 5:08 ` Namhyung Kim
2015-11-17 13:53 ` [PATCH v11 16/24] perf config: Add '--system' and '--user' options to select which config file is used Taeung Song
2015-11-18 5:11 ` Namhyung Kim [this message]
2015-11-17 13:53 ` [PATCH v11 17/24] perf config: Collect configs to handle config variables Taeung Song
2015-11-18 5:15 ` Namhyung Kim
2016-03-04 12:45 ` Taeung Song
2016-03-04 13:58 ` Namhyung Kim
2016-03-05 2:55 ` Taeung Song
2015-11-17 13:53 ` [PATCH v11 18/24] perf config: Add 'list-all' option to perf-config Taeung Song
2015-11-17 13:53 ` [PATCH v11 19/24] perf config: Add a option 'skel' " Taeung Song
2015-11-17 13:53 ` [PATCH v11 20/24] perf config: Add --verbose option for showing config description Taeung Song
2015-11-17 13:53 ` [PATCH v11 21/24] perf config: Add 'get' functionality Taeung Song
2015-11-17 13:53 ` [PATCH v11 22/24] perf config: Add 'set' feature Taeung Song
2015-11-17 13:53 ` [PATCH v11 23/24] perf config: normalize a value depending on default type of it Taeung Song
2015-11-17 13:53 ` [PATCH v11 24/24] perf config: Add a option 'remove' to perf-config Taeung Song
2015-11-17 22:36 ` [PATCH v11 01/24] perf tools: Add 'perf-config' command Namhyung Kim
2015-11-26 8:20 ` [tip:perf/core] perf tools: Add 'perf config' command tip-bot for 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=20151118051110.GO7062@sejong \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.