Re: "perf hists browser: Support flat callchains" appears to have broken parent reporting

From: Andres Freund
Date: Wed Mar 30 2016 - 15:03:08 EST


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.