From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764190AbcISIAK (ORCPT ); Mon, 19 Sep 2016 04:00:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59148 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760007AbcISIAD (ORCPT ); Mon, 19 Sep 2016 04:00:03 -0400 Date: Mon, 19 Sep 2016 09:59:54 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Andi Kleen Subject: Re: [PATCH 2/7] perf hist: Introduce hists__link_hierarchy() Message-ID: <20160919075954.GB26906@krava> References: <20160913074552.13284-1-namhyung@kernel.org> <20160913074552.13284-3-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160913074552.13284-3-namhyung@kernel.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 19 Sep 2016 07:59:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 13, 2016 at 04:45:47PM +0900, Namhyung Kim wrote: > The hists__link_hierarchy() is to support hierarchy report with event > group. When it matches leader event and other members (with the > hists__match_hierarchy), it also needs to link unmatched member entries > with a dummy leader event so that it can show up in the output. SNIP > > +static int hists__link_hierarchy(struct hists *leader_hists, > + struct hist_entry *parent, > + struct rb_root *leader_root, > + struct rb_root *other_root) > +{ > + struct rb_node *nd; > + struct hist_entry *pos, *leader; > + > + for (nd = rb_first(other_root); nd; nd = rb_next(nd)) { > + pos = rb_entry(nd, struct hist_entry, rb_node_in); > + > + if (hist_entry__has_pairs(pos)) { > + bool found = false; > + > + list_for_each_entry(leader, &pos->pairs.head, pairs.node) { > + if (leader->hists == leader_hists) { > + found = true; > + break; > + } > + } > + if (!found) > + return -1; > + } else { > + leader = add_dummy_hierarchy_entry(leader_hists, > + leader_root, pos); could we call hists__add_dummy_entry in here? seems like there's only difference in function arguments.. we could safe one function ;-) thanks, jirka