linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 2/5] perf hists: Exchange order of comparing items when collapsing hists
Date: Fri, 7 Dec 2012 11:18:53 +0100	[thread overview]
Message-ID: <20121207101853.GA1015@krava.brq.redhat.com> (raw)
In-Reply-To: <874njydzpd.fsf@sejong.aot.lge.com>

On Fri, Dec 07, 2012 at 05:38:22PM +0900, Namhyung Kim wrote:
> Hi Arnaldo,
> 

SNIP

> @@ -739,6 +739,10 @@ static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
>  
>                 cmp = hist_entry__collapse(he, pair);
>  
> +               if (sort__need_collapse)
> +                       cmp = hist_entry__collapse(he, pair);
> +               else
> +                       cmp = hist_entry__cmp(pair, he);
>                 if (!cmp)
>                         goto out;
>  
> @@ -772,7 +776,12 @@ static struct hist_entry *hists__find_entry(struct hists *hists,
>  
>         while (n) {
>                 struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node_in);
> -               int64_t cmp = hist_entry__collapse(iter, he);
> +               int64_t cmp;
> +
> +               if (sort__need_collapse)
> +                       cmp = hist_entry__collapse(iter, he);
> +               else
> +                       cmp = hist_entry__cmp(he, iter);
>  
>                 if (cmp < 0)
>                         n = n->rb_left;
> 
> It doesn't look good, especially hist_entry__collapse will be same as
> hist_entry__cmp if 'sort__need_collapse' is false.  If we can make the
> order consistent, it'd be converted to a sigle _collapse() call
> without the conditional.
> 
> Thanks,
> Namhyung

I've got non matching entries in diff after applying just patch 2/5,
and it's caused by missing he/iter swap in initial name resort in
insert_hist_entry_by_name function.

I understand that function goes away in your next patch while
add_hist_entry (swap ok) being the one doing initial name resort,
but still.. took me some time to figure this out ;)

jirka

---
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index b2e7d39..4dda6f4 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -285,7 +285,7 @@ static void insert_hist_entry_by_name(struct rb_root *root,
 	while (*p != NULL) {
 		parent = *p;
 		iter = rb_entry(parent, struct hist_entry, rb_node);
-		if (hist_entry__cmp(he, iter) < 0)
+		if (hist_entry__cmp(iter, he) < 0)
 			p = &(*p)->rb_left;
 		else
 			p = &(*p)->rb_right;

  reply	other threads:[~2012-12-07 10:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-06 15:09 [PATCH 0/5] perf hists: Changes on hists__{match,link} (v3) Namhyung Kim
2012-12-06 15:09 ` [PATCH 1/5] perf diff: Removing displacement output option Namhyung Kim
2012-12-06 15:09 ` [PATCH 2/5] perf hists: Exchange order of comparing items when collapsing hists Namhyung Kim
2012-12-06 16:53   ` Jiri Olsa
2012-12-06 19:09     ` Arnaldo Carvalho de Melo
2012-12-07  8:38       ` Namhyung Kim
2012-12-07 10:18         ` Jiri Olsa [this message]
2012-12-06 15:09 ` [PATCH 3/5] perf hists: Link hist entries before inserting to an output tree Namhyung Kim
2012-12-06 16:25   ` Jiri Olsa
2012-12-07  8:45     ` Namhyung Kim
2012-12-06 15:09 ` [PATCH 4/5] perf diff: Use internal rb tree for compute resort Namhyung Kim
2012-12-06 16:51   ` Jiri Olsa
2012-12-07  8:53     ` Namhyung Kim
2012-12-06 15:09 ` [PATCH 5/5] perf test: Add a test case for hists__{match,link} 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=20121207101853.GA1015@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@ghostprotocols.net \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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).