From patchwork Mon Jul 31 09:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 128599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1944070vqg; Mon, 31 Jul 2023 04:21:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFw44qGa/fd9SVPhUwEMXISMo93282cUmUnVzHf8k4ok8e/oKLUku5FIf5VwgOf498PyTUE X-Received: by 2002:a05:6512:32ce:b0:4fe:62f:35eb with SMTP id f14-20020a05651232ce00b004fe062f35ebmr7167724lfg.20.1690802474568; Mon, 31 Jul 2023 04:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690802474; cv=none; d=google.com; s=arc-20160816; b=OPOz+TxqjkLS2I8tIsJyMZSjm9368WdrvElVVu23b1iIDAZGBnwCww45raNLfIHjRo jn9mgCTv4TRAFC7bLCPDwyhGnSrq0esDpneFHj4goCvTKPxcM6SzuGfBrsisXlAD3uIO u154PXDqlP5cj7CevulxRdnFCg6ivKE3RuWEHUiVPGUFqo6l/GPGPZeQy528lJ9n5RKe bgmThoSWMzROMW9HjbBD/kQTEQeFJlGuiQa86PJWWaFp0r9iDPWEviSoCj1RSy+8IgBX 3JC6ngDnlaQr0L9qktrwhBpcI/5RWJJYIdxA2z1I7czTMQIo6NsfNUAgQWf23EJaIIaN ldMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=NVTfBN5N9lCiJFglea9HccCPavQm9AmSWqbL+0BDsu8=; fh=oDOBpmTiyl9swx1Nx4obqooo6P8COg4xGpp1uPO2Nmc=; b=uO2ij9DJsZ14Ucsj0Dr0OdkrO1BaG6vF0pvtuuen2ym1JK9dgn8l0yfbkZedU2L9vV 2H4LISixTGGU3g2u/iKaYJuC4B6xaXJTyr44j2mjOUpGU5HBTlrKW45LK51eST/HEVvs nWVxfJYrKADxQYOdGFt2Fuw3Utrr11PMV+v/9BrX7C3+2jZKN50vt1bdyfnmZeg0kXWR 2ekDKF/8v/h0SQMXmRqAIjMTuq+aTfGL7wtUUtt/wfGNEDd2e7hs/rm5vFZP6IxNGrNq cyO0g9VA8y+jDnhV/Ptdog8xovQTVkCXQxgHgNoV1b3kQjaFsK/Y9QDzepJSy411tm1k 2Z9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SZ5yC6WE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020aa7c448000000b0051dd525dd79si5673328edr.521.2023.07.31.04.20.50; Mon, 31 Jul 2023 04:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SZ5yC6WE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbjGaJvD (ORCPT + 99 others); Mon, 31 Jul 2023 05:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbjGaJug (ORCPT ); Mon, 31 Jul 2023 05:50:36 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F8F19B0; Mon, 31 Jul 2023 02:49:40 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686efa1804eso2988056b3a.3; Mon, 31 Jul 2023 02:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690796980; x=1691401780; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=NVTfBN5N9lCiJFglea9HccCPavQm9AmSWqbL+0BDsu8=; b=SZ5yC6WE9LxSRAcxOxJT8x45C7+LJ4saf6KPzt8jTuIx9bxWK2FyxtaboxNway8jfB cnJDOSprxQOy/1+88C0yQS5At9EpKGKmxIaBKRb/YvhISFRnjk9gkgtFAWRzb1tNGPns 8HmpI/2YrMIJDtNnf6Kw7PcboQK+1uayVqTCkYl1Yd2qNGDhGqzvwTttziUV2jGPCZjx IQx8NCFs5yqMUdH6s/OkDcTdcitf3raYPR2FN3M8XjrvYbZV0k6yA5IwzJOSTh9krSVC ZM3QRPVmyOPagpHs7k88p1KtvRO27S/oJWh8TZtXah/RjoiTgUzNTpiDK0kCZ7/YP9p2 EOLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690796980; x=1691401780; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NVTfBN5N9lCiJFglea9HccCPavQm9AmSWqbL+0BDsu8=; b=lzFGxXvs/iOXKpJzRMbojoMbBTrosCb2bpfx1Nmep+JXp1xTNPiyiAkqu0IAkLWuX5 CrE7xK04wDsEYQBI7Bj1ih8cH5DH1RZw3L7QE/6yAFgWj8Cd0m4PzCbeLTJIigDRfiTZ OSQ2jFpNjvyfLP4PAPIrPpKKhST2deLOwiWUJhZz3UmwUmm8LgR+k9KauoxLKxqg5XRS QaDhMcof8LmXvssiM9jI3zRDWDyWtLhLdh8/CIDOZaq7OgIxzsAZHkPzLIT+n36G0Anc oSp4ozdzEVGaOYQXmAAzaI831QiTrYAqK6XwdxC3lI/ApdQZac85zglfU8fMkgITqOyy 19uA== X-Gm-Message-State: ABy/qLbH4w6Nm/420ZTDOixqz1RIW6/HwA2bKonKsFvrzS+9ftjNUtcg fPydZZa+hWg1S5++oQTEzjc= X-Received: by 2002:a05:6a21:329e:b0:13d:df16:cf29 with SMTP id yt30-20020a056a21329e00b0013ddf16cf29mr2138744pzb.15.1690796980158; Mon, 31 Jul 2023 02:49:40 -0700 (PDT) Received: from bangji.roam.corp.google.com ([117.111.1.150]) by smtp.gmail.com with ESMTPSA id w5-20020a170902d3c500b001bbd1562e75sm8117852plb.55.2023.07.31.02.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 02:49:39 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] perf hists browser: Fix hierarchy mode header Date: Mon, 31 Jul 2023 02:49:32 -0700 Message-ID: <20230731094934.1616495-1-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772934895631855137 X-GMAIL-MSGID: 1772934895631855137 The commit ef9ff6017e3c4 ("perf ui browser: Move the extra title lines from the hists browser") introduced ui_browser__gotorc_title() to help moving non-title lines easily. But it missed to update the title for the hierarchy mode so it won't print the header line on TUI at all. $ perf report --hierarchy Fixes: ef9ff6017e3c4 ("perf ui browser: Move the extra title lines from the hists browser") Cc: stable@vger.kernel.org Signed-off-by: Namhyung Kim --- 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 c7ad9e003080..d8b88f10a48d 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1779,7 +1779,7 @@ static void hists_browser__hierarchy_headers(struct hist_browser *browser) hists_browser__scnprintf_hierarchy_headers(browser, headers, sizeof(headers)); - ui_browser__gotorc(&browser->b, 0, 0); + ui_browser__gotorc_title(&browser->b, 0, 0); ui_browser__set_color(&browser->b, HE_COLORSET_ROOT); ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1); } From patchwork Mon Jul 31 09:49:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 128601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1944681vqg; Mon, 31 Jul 2023 04:22:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+8Ge7moacMkuABWQxayo6dO8SyiUNOlrX1zee/8XByCsfC7cooexjzZrcyntsQ7iU5koV X-Received: by 2002:aa7:d48a:0:b0:522:45db:48e3 with SMTP id b10-20020aa7d48a000000b0052245db48e3mr7773663edr.30.1690802543058; Mon, 31 Jul 2023 04:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690802543; cv=none; d=google.com; s=arc-20160816; b=EAjxhqAuNQpO66eiJQrge6+Z/MlFc8A6MWUdmXJx7kH6KHyt7AhaqHml6ROieae/GX yIAEkYSxrNQ7+Su1poy7HkDU/ZKLXwbWoYLZIg97aNTYmJHLz4OAbE68tEkDxwPiSUwO yxzfNakebvVhWI82zC/pe3DKQBsVp5AzJsd124IunwmO9EC24mU290oO7jampjEPNe8W IpiShfNE7cWPs0adHx2XiPZVUNR/X5IGkotx7lEmgVjmOMk151tdMkVFxIRg/4SoxDwe dkK+nbvZv3+1dbBZDlmBJM8inqXu8Hv+tFQO1I/rfPhfRDfNqaYN1zzGf+o9ib9Uslzi OU+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=srChBgqkK2HgGpCSRgI2R97JsxAcdTHmiRn2ciHkn/Y=; fh=oDOBpmTiyl9swx1Nx4obqooo6P8COg4xGpp1uPO2Nmc=; b=PUAkCcwFU1EZ4ZIUhSphXUXsTFe9sQ+n9v58O+ngxKyHgK0xWs1E/HnnB6R6Xw0DPc VlpUBll1FAS4EY/+robnh+1us6UJ/i3nEfH6pKxq0Mc9nqXpI0uNJCZFl3usGlB4O/Gj k6XXZ4kc3kzFrX+rjijaa966n+Hfr3vtp0jH/CGR2s/axq3GQmHAnG2Gubq2iXc+BlTD DJym5RjD4QvguRTH7jXO7/eunUxy0Uqc6uBM7k8e2gZNO6FmLKmB0cJukEPens36XvYO uapGbXVlW21q8ZHoBIHnN7f8kapoCZWli6jX61AEARjMpMwNTbpqmnhjBlOrEN5A4BS/ WwmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=p1r5iHFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a05640203ca00b0052256067f49si4897650edw.414.2023.07.31.04.21.59; Mon, 31 Jul 2023 04:22:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=p1r5iHFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbjGaJvG (ORCPT + 99 others); Mon, 31 Jul 2023 05:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjGaJui (ORCPT ); Mon, 31 Jul 2023 05:50:38 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E56C91BD2; Mon, 31 Jul 2023 02:49:43 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686f38692b3so4077682b3a.2; Mon, 31 Jul 2023 02:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690796983; x=1691401783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=srChBgqkK2HgGpCSRgI2R97JsxAcdTHmiRn2ciHkn/Y=; b=p1r5iHFCJoYcfwDUrmDWxBxPw6HqRaQG3xB8yYmbvEY+VYS7gw4oolqV+Z/nnfYg5M oEV7LlRg5v/1Bt84bYMiW8YjIA7p3L0RxTyU3rreH8LVurcwMhXijRz7jAPR/vWwY0IY tQs/4WJ0qFxqb9By1De8gqvGMlQCa2pWz6hN2dwl0pxx0L3G3lXcu0v0etR8rbwONHuH AL9BK9mquSqih5nFnop3SNa5QXcKOfUR3DvZ9mPo//l8b1dGvOQYfSQXIt7Ur7ayzqJz i4VcNeSLb65rPUUtBulKhqNvjkIOVqdhkm/MVWWsV3uglHHHGO3gS56UHxK852Zyat8B UsPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690796983; x=1691401783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=srChBgqkK2HgGpCSRgI2R97JsxAcdTHmiRn2ciHkn/Y=; b=Axi44AwssO3ODLFVW02E+wewwsKLP5T8AXfG6BJwLWJiAxO/al0NLmbTV5kWHQlZ98 5pOuXyQlGNJE1bAriRipCawWCOBtZaXw3GS/IwHS1tBkewiYlAxqApEY+fIeJjcOCQ7l PKC3Q1lxKD9GZiVOB8N7k9aURS7OgjqU817M5onoFxt0xJE6Wws4NM0JxHbWPCFAegFl mBoDSC61yHDOAo5SO4/v7XRowLfWH7Tbm9Hny9Jy4ZNk5JlAXquD34Rg6kOH8/s4TqFn a2faCf2U6pwOtEc/SyjZYCZfrOE7X9pWXAY6A4WsGiXDpJvd5+9y6x1tQ/Bzwuka7ktO PLDA== X-Gm-Message-State: ABy/qLZAaud8tpAT3dnxsPS4UYK7ZsYPKo63wweXBi1ZuwRriuxg9b51 y506/P8fe8dI69OU6jyq4oE= X-Received: by 2002:a05:6a21:a105:b0:133:ebf2:96da with SMTP id aq5-20020a056a21a10500b00133ebf296damr8970908pzc.41.1690796983236; Mon, 31 Jul 2023 02:49:43 -0700 (PDT) Received: from bangji.roam.corp.google.com ([117.111.1.150]) by smtp.gmail.com with ESMTPSA id w5-20020a170902d3c500b001bbd1562e75sm8117852plb.55.2023.07.31.02.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 02:49:42 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/2] perf hists browser: Fix the number of entries for 'e' key Date: Mon, 31 Jul 2023 02:49:33 -0700 Message-ID: <20230731094934.1616495-2-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230731094934.1616495-1-namhyung@kernel.org> References: <20230731094934.1616495-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772934967136072517 X-GMAIL-MSGID: 1772934967136072517 The 'e' key is to toglle expand/collapse the selected entry only. But the current code has a bug that it only increases the number of entries by 1 in the hierarchy mode so users cannot move under the current entry after the key stroke. This is due to a wrong assumption in the hist_entry__set_folding(). The commit b33f922651011 ("perf hists browser: Put hist_entry folding logic into single function") factored out the code, but actually it should be handled separately. The hist_browser__set_folding() is to update fold state for each entry so it needs to traverse all (child) entries regardless of the current fold state. So it increases the number of entries by 1. But the hist_entry__set_folding() only cares the currently selected entry and its all children. So it should count all unfolded child entries. This code is implemented in hist_browser__toggle_fold() already so we can just call it. Fixes: b33f922651011 ("perf hists browser: Put hist_entry folding logic into single function") Cc: stable@vger.kernel.org Signed-off-by: Namhyung Kim --- tools/perf/ui/browsers/hists.c | 58 ++++++++++++++-------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index d8b88f10a48d..70db5a717905 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -407,11 +407,6 @@ static bool hist_browser__selection_has_children(struct hist_browser *browser) return container_of(ms, struct callchain_list, ms)->has_children; } -static bool hist_browser__he_selection_unfolded(struct hist_browser *browser) -{ - return browser->he_selection ? browser->he_selection->unfolded : false; -} - static bool hist_browser__selection_unfolded(struct hist_browser *browser) { struct hist_entry *he = browser->he_selection; @@ -584,8 +579,8 @@ static int hierarchy_set_folding(struct hist_browser *hb, struct hist_entry *he, return n; } -static void __hist_entry__set_folding(struct hist_entry *he, - struct hist_browser *hb, bool unfold) +static void hist_entry__set_folding(struct hist_entry *he, + struct hist_browser *hb, bool unfold) { hist_entry__init_have_children(he); he->unfolded = unfold ? he->has_children : false; @@ -603,34 +598,12 @@ static void __hist_entry__set_folding(struct hist_entry *he, he->nr_rows = 0; } -static void hist_entry__set_folding(struct hist_entry *he, - struct hist_browser *browser, bool unfold) -{ - double percent; - - percent = hist_entry__get_percent_limit(he); - if (he->filtered || percent < browser->min_pcnt) - return; - - __hist_entry__set_folding(he, browser, unfold); - - if (!he->depth || unfold) - browser->nr_hierarchy_entries++; - if (he->leaf) - browser->nr_callchain_rows += he->nr_rows; - else if (unfold && !hist_entry__has_hierarchy_children(he, browser->min_pcnt)) { - browser->nr_hierarchy_entries++; - he->has_no_entry = true; - he->nr_rows = 1; - } else - he->has_no_entry = false; -} - static void __hist_browser__set_folding(struct hist_browser *browser, bool unfold) { struct rb_node *nd; struct hist_entry *he; + double percent; nd = rb_first_cached(&browser->hists->entries); while (nd) { @@ -640,6 +613,21 @@ __hist_browser__set_folding(struct hist_browser *browser, bool unfold) nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD); hist_entry__set_folding(he, browser, unfold); + + percent = hist_entry__get_percent_limit(he); + if (he->filtered || percent < browser->min_pcnt) + continue; + + if (!he->depth || unfold) + browser->nr_hierarchy_entries++; + if (he->leaf) + browser->nr_callchain_rows += he->nr_rows; + else if (unfold && !hist_entry__has_hierarchy_children(he, browser->min_pcnt)) { + browser->nr_hierarchy_entries++; + he->has_no_entry = true; + he->nr_rows = 1; + } else + he->has_no_entry = false; } } @@ -659,8 +647,10 @@ static void hist_browser__set_folding_selected(struct hist_browser *browser, boo if (!browser->he_selection) return; - hist_entry__set_folding(browser->he_selection, browser, unfold); - browser->b.nr_entries = hist_browser__nr_entries(browser); + if (unfold == browser->he_selection->unfolded) + return; + + hist_browser__toggle_fold(browser); } static void ui_browser__warn_lost_events(struct ui_browser *browser) @@ -732,8 +722,8 @@ static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_l hist_browser__set_folding(browser, true); break; case 'e': - /* Expand the selected entry. */ - hist_browser__set_folding_selected(browser, !hist_browser__he_selection_unfolded(browser)); + /* Toggle expand/collapse the selected entry. */ + hist_browser__toggle_fold(browser); break; case 'H': browser->show_headers = !browser->show_headers;