LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: "perf hists browser: Support flat callchains" appears to have broken parent reporting
Date: Wed, 30 Mar 2016 21:02:45 +0200
Message-ID: <20160330190245.GB13305@awork2.anarazel.de> (raw)
In-Reply-To: <20160330160010.GA1557@danjae>

Hi!

On 2016-03-31 01:00:10 +0900, Namhyung Kim wrote:
> On Wed, Mar 30, 2016 at 04:19:26PM +0200, Andres Freund wrote:
> > On 2016-03-30 10:46:34 -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Wed, Mar 30, 2016 at 02:34:18PM +0200, Andres Freund escreveu:
> > > > Hi,
> > > > 
> > > > 4b3a3212233a - "perf hists browser: Support flat callchains" seems to
> > > > have broken callchain display in tui mode when using !flat mode, or at
> > > > least changed it in an unintended manner.
> > > 
> > > humm, at first I thought this would be related to --percent-limit...
> > 
> > I'm not using --percent-limit. Just to be sure, I did explicitly set it
> > to various values, and it looks unrelated.
> > 
> > > What tree/branch are you using? Can you try pressing 'L' to play with
> > > the percent limit?
> > 
> > I'm primarily using linus' tree, and bisected the behavioural down to
> > that individual commit.
> 
> Thanks for reporting and finding this!

No problem.  I'm somewhat surprised to be the first to report this, the
behavioural change confused me quite a bit.  Maybe it took others about
as long as me to figure out it's actually a perf report problem ;)

> > I don't know the perf code at all, but skimming through the commit, the
> > following hunk looks suspicious:
> > 
> > @@ -263,7 +295,7 @@ static void callchain_node__init_have_children(struct callchain_node *node,
> >     chain = list_entry(node->val.next, struct callchain_list, list);
> >     chain->has_children = has_sibling;
> >  
> > -   if (!list_empty(&node->val)) {
> > +   if (node->val.next != node->val.prev) {
> >         chain = list_entry(node->val.prev, struct callchain_list, list);
> >         chain->has_children = !RB_EMPTY_ROOT(&node->rb_root);
> >     }
> > 
> > Reverting that individual change fixes things.  I'm not actually sure
> > what the post 4b3a3212233a version actually tests for?
> 
> Yeah, this is it.  It's my fault that I thought if the first chain
> (node->val.next) was set by has_sibling, no need to go to the body
> of the "if" statement when next == prev case.  But it's not...

> Do you mind resending the fix as a formal patch with my ack ?

Done.

I couldn't really explain the problem, so I handwaved the actual problem
away: I've not really grasped how the rbtree, callchain_lists and
callchain_node are intertwined.

My symptom description probably is inaccurate as well.


>From 017d80e3c98c7237183ac20bb1cfc81bd5e9a474 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 30 Mar 2016 19:39:28 +0200
Subject: [PATCH] perf hists: Fix determination of a callchain node's
 childlessness.

4b3a3212233a ("perf hists browser: Support flat callchains")
over-aggressively tried to optimize
callchain_node__init_have_children().

That lead to --tui mode not allowing to expand call chain elements if a
call chain element had only one parent. That's why --inverted callgraphs
looked halfway sane, but plain ones didn't.

Revert that individual optimization, it wasn't really related to the
rest of the commit.

Fixes: 4b3a3212233a042f48b7b8fedc64933e1ccd8643

Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Andres Freund <andres@anarazel.de>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 4b98165..2a83414 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -337,7 +337,7 @@ static void callchain_node__init_have_children(struct callchain_node *node,
 	chain = list_entry(node->val.next, struct callchain_list, list);
 	chain->has_children = has_sibling;
 
-	if (node->val.next != node->val.prev) {
+	if (!list_empty(&node->val)) {
 		chain = list_entry(node->val.prev, struct callchain_list, list);
 		chain->has_children = !RB_EMPTY_ROOT(&node->rb_root);
 	}
-- 
2.7.0.229.g701fa7f.dirty

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 12:34 Andres Freund
2016-03-30 13:46 ` Arnaldo Carvalho de Melo
2016-03-30 14:19   ` Andres Freund
2016-03-30 16:00     ` Namhyung Kim
2016-03-30 19:02       ` Andres Freund [this message]
2016-03-31  6:33         ` [tip:perf/urgent] perf hists: Fix determination of a callchain node's childlessness tip-bot for Andres Freund
2016-04-16 19:46           ` Andres Freund
2016-04-18 14:07             ` Arnaldo Carvalho de Melo
2016-04-18 14:25           ` Andres Freund
2016-05-02 22:17             ` Greg KH
2016-05-02 22:25               ` Andres Freund
2016-05-02 23:24                 ` Greg KH
2016-05-02 23:34                   ` Andres Freund
2016-03-30 21:07       ` "perf hists browser: Support flat callchains" appears to have broken parent reporting Arnaldo Carvalho de Melo

Reply instructions:

You may reply publically 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=20160330190245.GB13305@awork2.anarazel.de \
    --to=andres@anarazel.de \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git