From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753263AbbCLHZ6 (ORCPT ); Thu, 12 Mar 2015 03:25:58 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:34708 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753207AbbCLHZz (ORCPT ); Thu, 12 Mar 2015 03:25:55 -0400 From: He Kuang To: , CC: , , , , , Subject: [PATCHv3] perf hists browser: Fix UI bug after fold/unfold Date: Thu, 12 Mar 2015 15:21:49 +0800 Message-ID: <1426144909-18951-1-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 2.2.0.33.gc18b867 In-Reply-To: <20150311134803.GF29070@kernel.org> References: <20150311134803.GF29070@kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.189] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.55013F7F.01CF,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 991d5f3be875b78d177335ab83cfbd06 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In perf hists browser, the fold/unfold stat of each hist entry is recorded but hb->nr_callchain_rows loses its value after zoom out and zoom in back. This causes a wrong row cursor range that restrict user to move down anymore. This bug can be reproduced as follows: $ perf record -g -e syscalls:* ls $ perf report Available samples ================================================================ 2 syscalls:sys_enter_mprotect <= [enter one of the entries] 2 syscalls:sys_exit_mprotect 13 syscalls:sys_enter_brk ... In the hists brower, unfold some of the items, now the cursor can reach to any rows: Children Self Command Shared Object Symbol ================================================================ - 100.00% 100.00% ls libuClibc-0.9.33.2.so [.] lstat64 - lstat64 16.67% 0x6469702e64 8.33% 0x646970 8.33% 0x617461 8.33% 0x65 - 16.67% 0.00% ls [unknown] [.]0x6469702e64 0x6469702e64 <= [cursor can reach to bottom line, everything is ok] Now, zoom back to "Available samples" and enter again: Children Self Command Shared Object Symbol ================================================================ - 100.00% 100.00% ls libuClibc-0.9.33.2.so [.] lstat64 - lstat64 16.67% 0x6469702e64 8.33% 0x646970 8.33% 0x617461 <= [cursor may stop here, can't move down anymore] 8.33% 0x65 - 16.67% 0.00% ls [unknown] [.]0x6469702e64 0x6469702e64 This patch recalculates hb->nr_callchain_rows to fix the bug. Signed-off-by: He Kuang --- tools/perf/ui/browsers/hists.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 1106bb8..0856209 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -48,6 +48,24 @@ static bool hist_browser__has_filter(struct hist_browser *hb) return hists__has_filter(hb->hists) || hb->min_pcnt; } +static int hist_browser__get_folding(struct hist_browser *browser) +{ + struct rb_node *nd; + struct hists *hists = browser->hists; + int unfolded_rows = 0; + + for (nd = rb_first(&hists->entries); + (nd = hists__filter_entries(nd, browser->min_pcnt)) != NULL; + nd = rb_next(nd)) { + struct hist_entry *he = + rb_entry(nd, struct hist_entry, rb_node); + + if (he->ms.unfolded) + unfolded_rows += he->nr_rows; + } + return unfolded_rows; +} + static u32 hist_browser__nr_entries(struct hist_browser *hb) { u32 nr_entries; @@ -57,6 +75,7 @@ static u32 hist_browser__nr_entries(struct hist_browser *hb) else nr_entries = hb->hists->nr_entries; + hb->nr_callchain_rows = hist_browser__get_folding(hb); return nr_entries + hb->nr_callchain_rows; } -- 2.2.0.33.gc18b867