All of lore.kernel.org
 help / color / mirror / Atom feed
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>
Subject: Re: [PATCH] perf config : Adding a command 'config' with a option '--list' and a document for it.
Date: Mon, 9 Feb 2015 11:31:51 +0900	[thread overview]
Message-ID: <20150209023151.GF24182@sejong> (raw)
In-Reply-To: <1423123517-8975-1-git-send-email-treeze.taeung@gmail.com>

Hi Taeung,

On Thu, Feb 05, 2015 at 05:05:17PM +0900, Taeung Song wrote:
> The perf configuration file contain many variables which can make
> the perf command's action more effective and more skilful.
> 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 a command 'config --list' and a document for it.
> 
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
>  tools/perf/Documentation/perf-config.txt | 140 +++++++++++++++++++++++++++++++
>  tools/perf/Makefile.perf                 |   1 +
>  tools/perf/builtin-config.c              |  56 +++++++++++++
>  tools/perf/builtin.h                     |   1 +
>  tools/perf/command-list.txt              |   1 +
>  tools/perf/perf.c                        |   1 +
>  6 files changed, 200 insertions(+)
>  create mode 100644 tools/perf/Documentation/perf-config.txt
>  create mode 100644 tools/perf/builtin-config.c
> 
> diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
> new file mode 100644
> index 0000000..c88b8e1
> --- /dev/null
> +++ b/tools/perf/Documentation/perf-config.txt
> @@ -0,0 +1,140 @@
> +perf-config(1)
> +==============
> +
> +NAME
> +----
> +perf-config - Get and set variables in configuration file.

So do you also plan to add support for setting config variables like
git-config with this? :)


> +
> +SYNOPSIS
> +--------
> +[verse]
> +'perf config' --list
> +
> +DESCRIPTION
> +-----------
> +You can manage variables in configuration file with this command.
> +
> +OPTIONS
> +-------
> +
> +-l::
> +--list::
> +        Show all variables with key and value into each sections.
> +
> +CONFIGURATION FILE
> +------------------
> +
> +The Perf configuration file contain many variables which can make
> +the perf command's action more effective, more skilful.
> +The '$HOME/.perfconfig' file is used to store a per-user configuration.
> +The file 'etc/perfconfig' or '$(sysconfdir)/.perfconf' can be used to

I think it's '/etc/perfconfig' or '$(sysconfdir)/perfconfig'.


> +store a system-wide default configuration.
> +
> +The variables are divided into sections. In each sections, the variables
> +can contain a key and values.
> +
> +EXAMPLES
> +------------
> +
> +Given a $HOME/.perfconfig like this:
> +
> +#
> +# This is the config file, and
> +# a '#' character indicates a comment
> +#
> +
> +[colors]
> +        # There are types of color which are red,
> +        # green, default, black, blue,
> +        # white, magenta, lightgray
> +        top = red, lightgray
> +        medium = green, lightgray
> +        normal = black, lightgray
> +        selected = lightgray, magenta
> +        code = blue, lightgray
> +        addr = magenta, lightgray
> +        root = default
> +
> +[tui]
> +        # Defaults if linked with libslang
> +        report = on
> +        annotate = on
> +        top = on
> +
> +[gtk]
> +        report = on
> +        annotate = on
> +        top = on
> +
> +[buildid]
> +        # Default, disable using /dev/null
> +        dir = /root/.debug
> +
> +[annotate]
> +        # Defaults
> +        hide_src_code = false
> +        use_offset = true
> +        jump_arrows = true
> +        show_nr_jumps = false
> +
> +[pager]
> +        # That a 'cmd' is true mean to use pager
> +        cmd = true
> +
> +[alias]
> +
> +[help]
> +        # Format can be man, info, web or html
> +        format = web
> +        autocorrect = 3
> +
> +[core]
> +        # fall through
> +
> +[hist]
> +        # a value of 'percentage' can be 'relative' or 'absolute'
> +        percentage = relative
> +
> +[ui]
> +        show-headers= true
> +
> +[call-graph]
> +        # fp (framepointer), dwarf
> +        # If you use 'Dwarf style',
> +        # you can add ', (dump-size)' to record-mode such as ', 24'
> +        record-mode = fp
> +
> +        dump-size = 24
> +
> +        # graph (graph absolute), flat, fractal (graph relative)
> +        print-type = graph
> +
> +        # caller, callee
> +        order = caller
> +
> +        # function, address
> +        sort-key = function
> +
> +        threshold = 13.3
> +        print-limit = 54.3
> +
> +[report]
> +        group = true
> +        percent-limit = 70.54
> +        children = true
> +        queue-size = 32
> +
> +[man]
> +        cmd =
> +        path =
> +        viewer =
> +
> +[record]
> +        # fall through
> +        call-graph =
> +
> +[top]
> +        # a 'call-graph' is fall through
> +        call-graph =
> +        children = true

While it's nice to list up all config variables in the example
section, it'd be much greater if you could describe them in more
detail like git-config manual page.

Thanks,
Namhyung


> +
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index aa6a504..e2083f4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -475,6 +475,7 @@ BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o
>  BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o
>  BUILTIN_OBJS += $(OUTPUT)bench/futex-requeue.o
>  
> +BUILTIN_OBJS += $(OUTPUT)builtin-config.o
>  BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
>  BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
>  BUILTIN_OBJS += $(OUTPUT)builtin-help.o
> diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
> new file mode 100644
> index 0000000..04a17d9
> --- /dev/null
> +++ b/tools/perf/builtin-config.c
> @@ -0,0 +1,56 @@
> +/*
> + * 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"
> +
> +static struct {
> +	bool list_action;
> +} params;
> +
> +static int show_all_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;
> +}
> +
> +static int
> +cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
> +{
> +	int ret = 0;
> +	const char * const config_usage[] = {
> +		"perf config --list",
> +		NULL
> +	};
> +	const struct option options[] = {
> +		OPT_BOOLEAN('l', "list", &params.list_action, "list up current configurations"),
> +		OPT_END()
> +	};
> +
> +	argc = parse_options(argc, argv, options, config_usage,
> +			     PARSE_OPT_STOP_AT_NON_OPTION);
> +	if (argc > 0) {
> +		if (strcmp(argv[0], "-") == 0)
> +			pr_warn("  Error: '-' is not supported.\n");
> +
> +		usage_with_options(config_usage, options);
> +	}
> +
> +	if (params.list_action)
> +		ret = perf_config(show_all_config, NULL);
> +
> +	return ret;
> +}
> diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h
> index b210d62..65aef3d 100644
> --- a/tools/perf/builtin.h
> +++ b/tools/perf/builtin.h
> @@ -17,6 +17,7 @@ extern int cmd_annotate(int argc, const char **argv, const char *prefix);
>  extern int cmd_bench(int argc, const char **argv, const char *prefix);
>  extern int cmd_buildid_cache(int argc, const char **argv, const char *prefix);
>  extern int cmd_buildid_list(int argc, const char **argv, const char *prefix);
> +extern int cmd_config(int argc, const char **argv, const char *prefix);
>  extern int cmd_diff(int argc, const char **argv, const char *prefix);
>  extern int cmd_evlist(int argc, const char **argv, const char *prefix);
>  extern int cmd_help(int argc, const char **argv, const char *prefix);
> diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
> index 0906fc4..37138c2 100644
> --- a/tools/perf/command-list.txt
> +++ b/tools/perf/command-list.txt
> @@ -7,6 +7,7 @@ perf-archive			mainporcelain common
>  perf-bench			mainporcelain common
>  perf-buildid-cache		mainporcelain common
>  perf-buildid-list		mainporcelain common
> +perf-config			mainporcelain common
>  perf-diff			mainporcelain common
>  perf-evlist			mainporcelain common
>  perf-inject			mainporcelain common
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 3700a7f..943e54c 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -36,6 +36,7 @@ struct cmd_struct {
>  static struct cmd_struct commands[] = {
>  	{ "buildid-cache", cmd_buildid_cache, 0 },
>  	{ "buildid-list", cmd_buildid_list, 0 },
> +	{ "config",	cmd_config,	0 },
>  	{ "diff",	cmd_diff,	0 },
>  	{ "evlist",	cmd_evlist,	0 },
>  	{ "help",	cmd_help,	0 },
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2015-02-09  2:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05  8:05 [PATCH] perf config : Adding a command 'config' with a option '--list' and a document for it Taeung Song
2015-02-09  2:31 ` Namhyung Kim [this message]
     [not found]   ` <85D86691-A0FB-4E36-B746-48516EFDDDD0@gmail.com>
2015-02-15 14:00     ` Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2015-03-07 12:30 Taeung
2015-03-09  8:17 ` Namhyung Kim
2015-03-09  9:18 ` Jiri Olsa

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=20150209023151.GF24182@sejong \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --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.