linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 14/14] perf diff: Add generic order option for compute sorting
Date: Thu, 29 Nov 2012 21:02:01 +0900	[thread overview]
Message-ID: <87a9u0obwm.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1354110769-2998-15-git-send-email-jolsa@redhat.com> (Jiri Olsa's message of "Wed, 28 Nov 2012 14:52:49 +0100")

On Wed, 28 Nov 2012 14:52:49 +0100, Jiri Olsa wrote:
> Adding option 'o' to allow sorting based on the
> input file number.
[snip]
>  hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
>  			int c)
>  {
> -	int i;
> +	struct hist_entry **pairs_left  = left->pairs;
> +	struct hist_entry **pairs_right = right->pairs;
> +	struct hist_entry *p_right, *p_left;
> +	static int64_t cmp;
>  
> -	for (i = 0; i < data_cnt; i++) {
> -		struct hist_entry **pairs_left  = left->pairs;
> -		struct hist_entry **pairs_right = right->pairs;
> -		struct hist_entry *p_right, *p_left;
> -		static int64_t cmp;
> +	if (!pairs_left || !pairs_right)
> +		return pairs_left ? -1 : 1;
>  
> -		if (!pairs_left || !pairs_right)
> -			return pairs_right - pairs_left;
> +	p_right = pairs_right[sort_compute];
> +	p_left  = pairs_left[sort_compute];
>  
> -		p_right = pairs_right[i];
> -		p_left  = pairs_left[i];
> +	if (!p_left || !p_right)
> +		return p_left ? -1 : 1;

What if both p_left and p_right are NULL?  Shouldn't it be move to the
next pairs?

>  
> -		if (!p_left || !p_right)
> -			return p_right - p_left;
> -
> -		/*
> -		 * If we differ, we are done, otherwise continue until all
> -		 * is processed or we find a difference.
> -		 */
> -		cmp = __hist_entry__cmp_compute(p_left, p_right, c);
> -		if (cmp)
> -			return cmp;
> -	}
> +	/*
> +	 * If we differ, we are done, otherwise continue until all
> +	 * is processed or we find a difference.
> +	 */

I guess this comment is not applied anymore.  Or we need a loop after
checking sort_compute column, right?

Thanks,
Namhyung


> +	cmp = __hist_entry__cmp_compute(p_left, p_right, c);
> +	if (cmp)
> +		return cmp;
>  
>  	return 0;
>  }
> @@ -759,6 +748,7 @@ static const struct option options[] = {
>  		   "columns '.' is reserved."),
>  	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
>  		    "Look for files with symbols relative to this directory"),
> +	OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
>  	OPT_END()
>  };
>  
> @@ -1087,6 +1077,11 @@ static int data_init(int argc, const char **argv)
>  		d->idx  = i;
>  	}
>  
> +	if (sort_compute >= (unsigned int) data_cnt) {
> +		pr_err("Order option out of limit.\n");
> +		return -EINVAL;
> +	}
> +
>  	return 0;
>  }

  reply	other threads:[~2012-11-29 12:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 13:52 [PATCH/RFC 00/14] perf, tool: Fix endian issues Jiri Olsa
2012-11-28 13:52 ` [PATCH 01/14] perf tool: Introduce perf_hpp__list for period related columns Jiri Olsa
2012-11-29  7:44   ` Namhyung Kim
2012-11-29 10:52     ` Namhyung Kim
2012-11-28 13:52 ` [PATCH 02/14] perf tool: Add struct perf_hpp_fmt into hpp callbacks Jiri Olsa
2012-11-28 13:52 ` [PATCH 03/14] perf tool: Fix period symbol_conf.field_sep display Jiri Olsa
2012-11-29  7:56   ` Namhyung Kim
2012-11-29 11:53     ` Jiri Olsa
2012-11-29 13:40       ` [PATCH] perf hists: Fix period symbol_conf.field_sep display, again Jiri Olsa
2012-11-29 17:35         ` Arnaldo Carvalho de Melo
2012-11-28 13:52 ` [PATCH 04/14] perf diff: Remove displacement from struct hist_entry_diff Jiri Olsa
2012-11-29  8:00   ` Namhyung Kim
2013-01-24 18:50   ` [tip:perf/core] " tip-bot for Jiri Olsa
2012-11-28 13:52 ` [PATCH 05/14] perf diff: Change compute methods to work with pair directly Jiri Olsa
2012-11-29 11:15   ` Namhyung Kim
2013-01-24 18:51   ` [tip:perf/core] " tip-bot for Jiri Olsa
2012-11-28 13:52 ` [PATCH 06/14] perf diff: Change formula " Jiri Olsa
2012-11-29 11:15   ` Namhyung Kim
2013-01-24 18:52   ` [tip:perf/core] " tip-bot for Jiri Olsa
2012-11-28 13:52 ` [PATCH 07/14] perf diff: Add callback to hists__match/hists__link functions Jiri Olsa
2012-11-28 13:52 ` [PATCH 08/14] perf diff: Change diff command to work over multiple data files Jiri Olsa
2012-11-29 11:37   ` Namhyung Kim
2012-11-29 11:53     ` Jiri Olsa
2012-11-28 13:52 ` [PATCH 09/14] perf diff: Update perf diff documentation for multiple data comparison Jiri Olsa
2012-11-29 11:52   ` Namhyung Kim
2012-11-29 12:06     ` Jiri Olsa
2012-11-28 13:52 ` [PATCH 10/14] perf tool: Centralize default columns init in perf_hpp__init Jiri Olsa
2012-11-29 11:55   ` Namhyung Kim
2012-11-29 12:13     ` Jiri Olsa
2012-11-30  5:06       ` Namhyung Kim
2012-11-30 11:56         ` Jiri Olsa
2012-11-28 13:52 ` [PATCH 11/14] perf diff: Making compute functions static Jiri Olsa
2012-11-28 13:52 ` [PATCH 12/14] perf diff: Display data file info ahead of the diff output Jiri Olsa
2012-11-28 13:52 ` [PATCH 13/14] perf diff: Display zero calculation results Jiri Olsa
2012-11-28 13:52 ` [PATCH 14/14] perf diff: Add generic order option for compute sorting Jiri Olsa
2012-11-29 12:02   ` Namhyung Kim [this message]
2012-11-29 12:19     ` Jiri Olsa
2012-11-28 13:56 ` [PATCH/RFC 00/14] perf, diff: Support for multiple files Jiri Olsa
2012-11-28 15:57   ` 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=87a9u0obwm.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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;
as well as URLs for NNTP newsgroup(s).