public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Andi Kleen <andi@firstfloor.org>, Jiri Olsa <jolsa@redhat.com>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH 10/10] perf sort: Consolidate sort_entry__setup_elide()
Date: Wed, 3 Apr 2013 14:09:44 -0300	[thread overview]
Message-ID: <20130403170944.GB7238@ghostprotocols.net> (raw)
In-Reply-To: <1364991979-3008-11-git-send-email-namhyung@kernel.org>

Em Wed, Apr 03, 2013 at 09:26:19PM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> The same code was duplicate to places, factor them out to common
> sort__setup_elide().

Looks ok, applying after fixing up fuzzes due to this being at the end
of the patchseries. Things like this that are clear cleanups are best
positioned in the start of the patch series.

- Arnaldo
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-diff.c   |  4 +---
>  tools/perf/builtin-report.c | 20 +-------------------
>  tools/perf/builtin-top.c    |  4 +---
>  tools/perf/util/sort.c      | 45 +++++++++++++++++++++++++++++++++++++++++++--
>  tools/perf/util/sort.h      |  3 +--
>  5 files changed, 47 insertions(+), 29 deletions(-)
> 
> diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
> index 03b56c542bb6..316bf13e59c7 100644
> --- a/tools/perf/builtin-diff.c
> +++ b/tools/perf/builtin-diff.c
> @@ -611,9 +611,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
>  
>  	setup_pager();
>  
> -	sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL);
> -	sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL);
> -	sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL);
> +	sort__setup_elide(NULL);
>  
>  	return __cmd_diff();
>  }
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index c95fd92fbd44..bff244fa4b5d 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -937,25 +937,7 @@ repeat:
>  		report.symbol_filter_str = argv[0];
>  	}
>  
> -	sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
> -
> -	if (sort__mode == SORT_MODE__BRANCH) {
> -		sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout);
> -		sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout);
> -		sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout);
> -		sort_entry__setup_elide(&sort_sym_to, symbol_conf.sym_to_list, "sym_to", stdout);
> -	} else {
> -		if (report.mem_mode) {
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "symbol_daddr", stdout);
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso_daddr", stdout);
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "mem", stdout);
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "local_weight", stdout);
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "tlb", stdout);
> -			sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "snoop", stdout);
> -		}
> -		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
> -		sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
> -	}
> +	sort__setup_elide(stdout);
>  
>  	ret = __cmd_report(&report);
>  	if (ret == K_SWITCH_INPUT_DATA) {
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 4aa504baaf0b..fe4acf568483 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -1201,9 +1201,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
>  	if (symbol__init() < 0)
>  		return -1;
>  
> -	sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
> -	sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
> -	sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
> +	sort__setup_elide(stdout);
>  
>  	get_term_dimensions(&top.winsize);
>  	if (top.print_entries == 0) {
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 213831133e08..86ae94d8782e 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1,5 +1,6 @@
>  #include "sort.h"
>  #include "hist.h"
> +#include "symbol.h"
>  
>  regex_t		parent_regex;
>  const char	default_parent_pattern[] = "^sys_|^do_page_fault";
> @@ -1085,8 +1086,9 @@ int setup_sorting(void)
>  	return ret;
>  }
>  
> -void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
> -			     const char *list_name, FILE *fp)
> +static void sort_entry__setup_elide(struct sort_entry *self,
> +				    struct strlist *list,
> +				    const char *list_name, FILE *fp)
>  {
>  	if (list && strlist__nr_entries(list) == 1) {
>  		if (fp != NULL)
> @@ -1095,3 +1097,42 @@ void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
>  		self->elide = true;
>  	}
>  }
> +
> +void sort__setup_elide(FILE *output)
> +{
> +	sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +				"dso", output);
> +	sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list,
> +				"comm", output);
> +	sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list,
> +				"symbol", output);
> +
> +	if (sort__mode == SORT_MODE__BRANCH) {
> +		sort_entry__setup_elide(&sort_dso_from,
> +					symbol_conf.dso_from_list,
> +					"dso_from", output);
> +		sort_entry__setup_elide(&sort_dso_to,
> +					symbol_conf.dso_to_list,
> +					"dso_to", output);
> +		sort_entry__setup_elide(&sort_sym_from,
> +					symbol_conf.sym_from_list,
> +					"sym_from", output);
> +		sort_entry__setup_elide(&sort_sym_to,
> +					symbol_conf.sym_to_list,
> +					"sym_to", output);
> +	} else if (sort__mode == SORT_MODE__MEMORY) {
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"symbol_daddr", output);
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"dso_daddr", output);
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"mem", output);
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"local_weight", output);
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"tlb", output);
> +		sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
> +					"snoop", output);
> +	}
> +
> +}
> diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
> index 1f945a3b2e5b..c80aac4ae3a2 100644
> --- a/tools/perf/util/sort.h
> +++ b/tools/perf/util/sort.h
> @@ -184,7 +184,6 @@ extern struct list_head hist_entry__sort_list;
>  
>  int setup_sorting(void);
>  extern int sort_dimension__add(const char *);
> -void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
> -			     const char *list_name, FILE *fp);
> +void sort__setup_elide(FILE *fp);
>  
>  #endif	/* __PERF_SORT_H */
> -- 
> 1.7.11.7

  reply	other threads:[~2013-04-03 17:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 12:26 [PATCHSET 00/10] perf tools: Cleanup for sort keys (v2) Namhyung Kim
2013-04-03 12:26 ` [PATCH 01/10] perf sort: Factor out common code in sort_dimension__add() Namhyung Kim
2013-05-31 11:19   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-04-03 12:26 ` [PATCH 02/10] perf sort: Separate out memory-specific sort keys Namhyung Kim
2013-05-31 11:20   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-06-25  0:30     ` Andi Kleen
2013-06-25  1:00       ` Namhyung Kim
2013-06-25  1:02         ` Andi Kleen
2013-06-25  1:06           ` Namhyung Kim
2013-04-03 12:26 ` [PATCH 03/10] perf sort: Add 'addr' sort key Namhyung Kim
2013-04-03 17:06   ` Arnaldo Carvalho de Melo
2013-04-04  0:49     ` Namhyung Kim
2013-04-03 12:26 ` [PATCH 04/10] perf sort: Add 'addr_to/from' " Namhyung Kim
2013-04-03 12:26 ` [PATCH 05/10] perf sort: Update documentation for sort keys Namhyung Kim
2013-04-03 12:26 ` [PATCH 06/10] perf hists: Move column length setting code Namhyung Kim
2013-04-03 12:26 ` [PATCH 07/10] perf sort: Cleanup sort__has_sym setting Namhyung Kim
2013-04-03 12:26 ` [PATCH 08/10] perf top: Use sort__has_sym Namhyung Kim
2013-04-03 12:26 ` [PATCH 09/10] perf hist browser: " Namhyung Kim
2013-04-03 17:07   ` Arnaldo Carvalho de Melo
2013-04-04  0:55     ` Namhyung Kim
2013-04-03 12:26 ` [PATCH 10/10] perf sort: Consolidate sort_entry__setup_elide() Namhyung Kim
2013-04-03 17:09   ` Arnaldo Carvalho de Melo [this message]
2013-04-04  0:56     ` Namhyung Kim
2013-05-31 11:21   ` [tip:perf/core] " 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=20130403170944.GB7238@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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