Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752231AbbKXF1N (ORCPT ); Tue, 24 Nov 2015 00:27:13 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:37469 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbbKXF1M (ORCPT ); Tue, 24 Nov 2015 00:27:12 -0500 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.150 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Tue, 24 Nov 2015 14:27:08 +0900 From: Namhyung Kim To: Frederic Weisbecker CC: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, Andi Kleen , David Ahern , Jiri Olsa , Kan Liang , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: Re: [PATCH 34/37] perf hists browser: Support flat callchains Message-ID: <20151124052708.GB2636@sejong> References: <1447955603-24895-1-git-send-email-acme@kernel.org> <1447955603-24895-35-git-send-email-acme@kernel.org> <20151123151647.GD3587@lerouge> MIME-Version: 1.0 In-Reply-To: <20151123151647.GD3587@lerouge> User-Agent: Mutt/1.5.24 (2015-08-30) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB02/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/11/24 14:27:08, Serialize by Router on LGEKRMHUB02/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/11/24 14:27:08, Serialize complete at 2015/11/24 14:27:08 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4460 Lines: 119 On Mon, Nov 23, 2015 at 04:16:48PM +0100, Frederic Weisbecker wrote: > On Thu, Nov 19, 2015 at 02:53:20PM -0300, Arnaldo Carvalho de Melo wrote: > > From: Namhyung Kim > > > > The flat callchain mode is to print all chains in a single, simple > > hierarchy so make it easy to see. > > > > Currently perf report --tui doesn't show flat callchains properly. With > > flat callchains, only leaf nodes are added to the final rbtree so it > > should show entries in parent nodes. To do that, add parent_val list to > > struct callchain_node and show them along with the (normal) val list. > > > > For example, consider following callchains with '-g graph'. > > > > $ perf report -g graph > > - 39.93% swapper [kernel.vmlinux] [k] intel_idle > > intel_idle > > cpuidle_enter_state > > cpuidle_enter > > call_cpuidle > > - cpu_startup_entry > > 28.63% start_secondary > > - 11.30% rest_init > > start_kernel > > x86_64_start_reservations > > x86_64_start_kernel > > > > Before: > > $ perf report -g flat > > - 39.93% swapper [kernel.vmlinux] [k] intel_idle > > 28.63% start_secondary > > - 11.30% rest_init > > start_kernel > > x86_64_start_reservations > > x86_64_start_kernel > > > > After: > > $ perf report -g flat > > - 39.93% swapper [kernel.vmlinux] [k] intel_idle > > - 28.63% intel_idle > > cpuidle_enter_state > > cpuidle_enter > > call_cpuidle > > cpu_startup_entry > > start_secondary > > - 11.30% intel_idle > > cpuidle_enter_state > > cpuidle_enter > > call_cpuidle > > cpu_startup_entry > > start_kernel > > x86_64_start_reservations > > x86_64_start_kernel > > > > Signed-off-by: Namhyung Kim > > Tested-by: Arnaldo Carvalho de Melo > > Tested-by: Brendan Gregg > > Cc: Andi Kleen > > Cc: David Ahern > > Cc: Frederic Weisbecker > > Cc: Jiri Olsa > > Cc: Kan Liang > > Cc: Peter Zijlstra > > Link: http://lkml.kernel.org/r/1447047946-1691-8-git-send-email-namhyung@kernel.org > > Signed-off-by: Arnaldo Carvalho de Melo > > --- > > [...] > > > +int callchain_node__make_parent_list(struct callchain_node *node) > > +{ > > + struct callchain_node *parent = node->parent; > > + struct callchain_list *chain, *new; > > + LIST_HEAD(head); > > + > > + while (parent) { > > + list_for_each_entry_reverse(chain, &parent->val, list) { > > + new = malloc(sizeof(*new)); > > + if (new == NULL) > > + goto out; > > + *new = *chain; > > + new->has_children = false; > > + list_add_tail(&new->list, &head); > > + } > > + parent = parent->parent; > > + } > > + > > + list_for_each_entry_safe_reverse(chain, new, &head, list) > > + list_move_tail(&chain->list, &node->parent_val); > > + > > + if (!list_empty(&node->parent_val)) { > > + chain = list_first_entry(&node->parent_val, struct callchain_list, list); > > + chain->has_children = rb_prev(&node->rb_node) || rb_next(&node->rb_node); > > + > > + chain = list_first_entry(&node->val, struct callchain_list, list); > > + chain->has_children = false; > > I'm a bit puzzled with this, can't we rewind through the parents on printing or adding > to the flat rbtree instead of having this parent_val field? Yes, this code is to simplify things on parent nodes. Maybe we could go up to parents and print the callchain list there as you said. However, problem I think is how to handle 'has_children' information on parents. That info controls folding status of each callchain. As the info is in the struct callchain_list and flat or folded callchain mode require the info should be in the top-most entry, I cannot share entries in parent nodes. Thus I simply copied callchain lists in parents to leaf nodes. Yes, it will consume some memory but can simplify the code. Thank you for your review anyway! Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/