linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Noel Grandin <noelgrandin@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string
Date: Thu, 7 Jan 2016 20:17:17 +0900	[thread overview]
Message-ID: <20160107111717.GG5499@danjae.kornet> (raw)
In-Reply-To: <1452158050-28061-12-git-send-email-jolsa@kernel.org>

On Thu, Jan 07, 2016 at 10:14:08AM +0100, Jiri Olsa wrote:
> We currently set 'overhead' and 'overhead_children'
> as default sort keys within perf_hpp__init function
> by directly adding into the sort list.
> 
> This patch adds 'overhead' and 'overhead_children'
> in text form into sort_keys and let them be added
> by standard sort dimension interface.
> 
> We need to eliminate dirrect sort_list additions to
> b able to add support for hists specific sort keys.
> 
> Link: http://lkml.kernel.org/n/tip-thk6jds1pi6j2jy82ywnxniy@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/ui/hist.c   | 12 ------------
>  tools/perf/util/sort.c | 39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> index 8263c0eb9fb5..bf2a66e254ea 100644
> --- a/tools/perf/ui/hist.c
> +++ b/tools/perf/ui/hist.c
> @@ -443,7 +443,6 @@ LIST_HEAD(perf_hpp__sort_list);
>  
>  void perf_hpp__init(void)
>  {
> -	struct list_head *list;
>  	int i;
>  
>  	for (i = 0; i < PERF_HPP__MAX_INDEX; i++) {
> @@ -484,17 +483,6 @@ void perf_hpp__init(void)
>  
>  	if (symbol_conf.show_total_period)
>  		hpp_dimension__add_output(PERF_HPP__PERIOD);
> -
> -	/* prepend overhead field for backward compatiblity.  */
> -	list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
> -	if (list_empty(list))
> -		list_add(list, &perf_hpp__sort_list);
> -
> -	if (symbol_conf.cumulate_callchain) {
> -		list = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC].sort_list;
> -		if (list_empty(list))
> -			list_add(list, &perf_hpp__sort_list);
> -	}
>  }
>  
>  void perf_hpp__column_register(struct perf_hpp_fmt *format)
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 04e2a5cb19e3..ec722346e6ff 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2252,6 +2252,34 @@ static int setup_sort_order(struct perf_evlist *evlist)
>  	return 0;
>  }
>  
> +/*
> + * Adds 'pre,' prefix into 'str' is 'pre' is
> + * not already part of 'str'.
> + */
> +static char *prefix_if_not_in(const char *pre, char *str)
> +{
> +	char *n;
> +
> +	if (!str || strstr(str, pre))
> +		return str;
> +
> +	if (asprintf(&n, "%s,%s", pre, str) < 0)
> +		return NULL;
> +
> +	free(str);
> +	return n;
> +}
> +
> +static char *setup_overhead(char *keys)
> +{
> +	keys = prefix_if_not_in("overhead", keys);
> +
> +	if (symbol_conf.cumulate_callchain)
> +		keys = prefix_if_not_in("overhead_children", keys);
> +
> +	return keys;
> +}
> +
>  static int __setup_sorting(struct perf_evlist *evlist)
>  {
>  	char *tmp, *tok, *str;
> @@ -2281,6 +2309,17 @@ static int __setup_sorting(struct perf_evlist *evlist)
>  		return -ENOMEM;
>  	}
>  
> +	/*
> +	 * Prepend overhead fields for backward compatibility.
> +	 */
> +	if (!is_strict_order(field_order)) {
> +		str = setup_overhead(str);
> +		if (str == NULL) {
> +			error("Not enough memory to setup overhead keys");
> +			return -ENOMEM;
> +		}
> +	}
> +
>  	for (tok = strtok_r(str, ", ", &tmp);
>  			tok; tok = strtok_r(NULL, ", ", &tmp)) {
>  		ret = sort_dimension__add(tok, evlist);
> -- 
> 2.4.3
> 

  reply	other threads:[~2016-01-07 11:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  9:13 [PATCHv2 00/13] perf tools: Various fixes Jiri Olsa
2016-01-07  9:13 ` [PATCH 01/13] perf tools: Remove perf_evlist__(enable|disable)_event functions Jiri Olsa
2016-01-09 16:40   ` [tip:perf/core] perf evlist: Remove perf_evlist__(enable|disable) _event functions tip-bot for Jiri Olsa
2016-01-07  9:13 ` [PATCH 02/13] perf tools: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does) Jiri Olsa
2016-01-09 16:40   ` [tip:perf/core] perf evlist: " tip-bot for Adrian Hunter
2016-01-07  9:14 ` [PATCH 03/13] perf tools: Use find_map function in access_dso_mem Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf unwind: " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 04/13] perf tools libunwind: Check for mmaps also in MAP__VARIABLE tree Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf unwind: " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 05/13] perf tools libdw: " Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 06/13] perf record: Store data mmaps for dwarf unwind Jiri Olsa
2016-01-07 11:12   ` Namhyung Kim
2016-01-07 12:39     ` [PATCHv2 " Jiri Olsa
2016-01-07 13:14       ` Namhyung Kim
2016-01-07 13:30         ` [PATCHv3 " Jiri Olsa
2016-01-07 20:42           ` Arnaldo Carvalho de Melo
2016-01-09 16:42           ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 07/13] perf tools: Do not show trace command if it's not compiled in Jiri Olsa
2016-01-09 16:37   ` [tip:perf/core] perf tools: Do not show trace command if it' s " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 08/13] perf script: Align event name properly Jiri Olsa
2016-01-09 16:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 09/13] perf tools: Include all tools/lib directory for tags/cscope/TAGS targets Jiri Olsa
2016-01-09 16:38   ` [tip:perf/core] perf tools: Include all tools/ lib " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 10/13] perf tools: Remove list entry from struct sort_entry Jiri Olsa
2016-01-07 11:13   ` Namhyung Kim
2016-01-09 16:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string Jiri Olsa
2016-01-07 11:17   ` Namhyung Kim [this message]
2016-01-09 16:39   ` [tip:perf/core] perf tools: Add overhead/ overhead_children " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 12/13] perf diff: Use perf_hpp__register_sort_field interface Jiri Olsa
2016-01-07 11:17   ` Namhyung Kim
2016-01-09 16:39   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 13/13] perf tools: Export a couple of hist functions Jiri Olsa
2016-01-09 16:39   ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim

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=20160107111717.GG5499@danjae.kornet \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=noelgrandin@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;
as well as URLs for NNTP newsgroup(s).