From patchwork Thu Oct 26 06:26:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 158411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp462385vqb; Wed, 25 Oct 2023 23:26:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmU4jJKzK0/8BPow1ssR0g6s9ZdOcDumUvxKiFIoP+EqCI9w5PIzVP/N5RSy+h5ggLroOT X-Received: by 2002:a25:7656:0:b0:d9a:3f66:1b16 with SMTP id r83-20020a257656000000b00d9a3f661b16mr3421870ybc.27.1698301585127; Wed, 25 Oct 2023 23:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698301585; cv=none; d=google.com; s=arc-20160816; b=idXqlTEkgGDpqUJ29sm+i7NEahmdWGR7PqDYRZKK3VOEA0LqVeDP15LWu4XmZjdgNk Fq9+q2X9yNik+2ZpGD0mVXjZGdNL7SAnHWfzZnFVo8StazuK4wlnJbMck1ocWNA1UZ5o hg28rKnsOFYi/rEyrBBvj0N94lFRKeCthbkMKQUw/dldvpM/wx7nLN2FVTDwhcYkEWdW v5nZBIYVftCdh+LbMvahRbN074s+KAtej3hQiJepm7MK9SHUex6JLJHvH/4vfmZw36y6 sHw0RxXlCX6Pz4UcKAs23MzvJ3/ij3uTFbKg3SfsqIQX20fssNb1b3iZMQUh5hIBRrZe f+bw== 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=KGFAGOw1jMD4qW4ZS/5Zs1JohmRnxW/EBkFlBVus7WE=; fh=/TViaxNXj9Ubl1KVZseJCqJutBKG0dvzf3DPkf/1G64=; b=OubVYd0Y5tccO33YxFIEHeTRLMQ7Ppw5yERfWS5jSGnVPxPgWK9UkO8wcwU2nkbOug NnbECmx/HORt0jSy0muf8fXSqKViNzupw8sB3IcoSoAUw32Tv1HRhEntbaBLqefCAsvz dAYTm39dniv+Jz5DfMYVzEim44EN23uZyInyPw5Ti5/YDSAUShm7Wm2bdaCm/Yh4YkM0 reGfCTI6Zc96kwZ9W4VawutJOxuePlNCaaq84WMljcCjUFPhBErAxh/jjL5Fowk7fEwp tYnbDnIZrEUjt7IgPxy/LaqewXkBNDeliHS9DhL/Pbo+C43uyOjil5/4kuppdWCGuXIn EQAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TVBgFX2s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o73-20020a25414c000000b00d852f0c38f0si12144564yba.591.2023.10.25.23.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 23:26:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TVBgFX2s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1B72881CC864; Wed, 25 Oct 2023 23:26:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344014AbjJZG0V (ORCPT + 26 others); Thu, 26 Oct 2023 02:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjJZG0U (ORCPT ); Thu, 26 Oct 2023 02:26:20 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12736187; Wed, 25 Oct 2023 23:26:18 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6bd73395bceso391633b3a.0; Wed, 25 Oct 2023 23:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698301577; x=1698906377; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=KGFAGOw1jMD4qW4ZS/5Zs1JohmRnxW/EBkFlBVus7WE=; b=TVBgFX2siBkLnhqsU680SN5MHyEkZYJTrAYsho5DJMDiKrnGYLmN/do+B0re8/H5gi KszNxjvPbLImN6HcJs6zH7Om8RygxM/fuTJqibDt82XsWynHMwOKnSObHybsSfzQszeZ AaPjbQgir6B/s9gAVF1nyQccCNGXuHHt6iiV2++KKbXiXIQ3aZM22JHOLDr3PZ6hsbFN h4kMBbhF12/pjJWlxEsbABV2qpGzy5KxjPLwI3G96fHMB7yE+U5mMYVX8XIK5MvbYgyf 7AlskJ/7gvFa5IMbuE6Q7s/VdJnxPQXojxEZDH8cTB20gL+nFWDSTF94pKNvfS/4pGTX nXHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698301577; x=1698906377; 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=KGFAGOw1jMD4qW4ZS/5Zs1JohmRnxW/EBkFlBVus7WE=; b=GBSeOr8eKQ7EHdrOQ0i7WrovnGjkbNCtQMed7xthRmI+6I82Cx95A66eH9m1hCubs7 N1/obMu7zNXGuZn2izAgZ3TQSHeM8OtfcX4AHTwQOoUTDojVuzGCMSHy/Ri8eCIqQUP5 Mdo0Ou9j53PLypwcY1jp1o8TutmfyHpxPwhIyre5yFqX9NgNqH21Xd9x0hrgcQ/tDIqU FqCeNGAe13taDml9gzlfqWL91qpubvcm3hiP1NFHvyA4fCx6zkEOjUIKpie/7zqGk4Js G14UlUXza6A9F3q8vomfpYsq19zbNiqKYXh+fUJd+mtD3rOPhlN4+RsfC49Ci/7D0bAD tA7w== X-Gm-Message-State: AOJu0Yzi2P7tOBbzcvf9wvEYGBvN7CGanQ0nAe1PC4n8QuFTyx3GMe70 d7BaufaPI2Mz5W9xdnmo3CM= X-Received: by 2002:a05:6a00:280f:b0:692:6417:728a with SMTP id bl15-20020a056a00280f00b006926417728amr1844186pfb.14.1698301577369; Wed, 25 Oct 2023 23:26:17 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:5393:ee8f:5738:b9c3]) by smtp.gmail.com with ESMTPSA id ca27-20020a056a00419b00b006c05374202dsm989282pfb.71.2023.10.25.23.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 23:26:16 -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 Subject: [PATCH] perf tools: Add -H short option for --hierarchy Date: Wed, 25 Oct 2023 23:26:15 -0700 Message-ID: <20231026062615.3096537-1-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-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_NONE,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 25 Oct 2023 23:26:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780798282787939833 X-GMAIL-MSGID: 1780798282787939833 I found the hierarchy mode useful, but it's easy to make a typo when using it. Let's add a short option for that. Also update the documentation. :) Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-report.txt | 29 ++++++++++++++++++++- tools/perf/Documentation/perf-top.txt | 32 +++++++++++++++++++++++- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 2 +- 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index af068b4f1e5a..7d8916b2b7f7 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -528,8 +528,35 @@ include::itrace.txt[] --raw-trace:: When displaying traceevent output, do not use print fmt or plugins. +-H:: --hierarchy:: - Enable hierarchical output. + Enable hierarchical output. In the hierarchy mode, each sort key groups + samples based on the criteria and then sub-divide it using the lower + level sort key. + + For example: + In normal output: + + perf report -s dso,sym + # Overhead Shared Object Symbol + 50.00% [kernel.kallsyms] [k] kfunc1 + 20.00% perf [.] foo + 15.00% [kernel.kallsyms] [k] kfunc2 + 10.00% perf [.] bar + 5.00% libc.so [.] libcall + + In hierarchy output: + + perf report -s dso,sym --hierarchy + # Overhead Shared Object / Symbol + 65.00% [kernel.kallsyms] + 50.00% [k] kfunc1 + 15.00% [k] kfunc2 + 30.00% perf + 20.00% [.] foo + 10.00% [.] bar + 5.00% libc.so + 5.00% [.] libcall --inline:: If a callgraph address belongs to an inlined function, the inline stack diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 3c202ec080ba..a754875fa5bb 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -261,8 +261,38 @@ Default is to monitor all CPUS. --raw-trace:: When displaying traceevent output, do not use print fmt or plugins. +-H:: --hierarchy:: - Enable hierarchy output. + Enable hierarchical output. In the hierarchy mode, each sort key groups + samples based on the criteria and then sub-divide it using the lower + level sort key. + + For example, in normal output: + + perf report -s dso,sym + # + # Overhead Shared Object Symbol + # ........ ................. ........... + 50.00% [kernel.kallsyms] [k] kfunc1 + 20.00% perf [.] foo + 15.00% [kernel.kallsyms] [k] kfunc2 + 10.00% perf [.] bar + 5.00% libc.so [.] libcall + + In hierarchy output: + + perf report -s dso,sym --hierarchy + # + # Overhead Shared Object / Symbol + # .......... ...................... + 65.00% [kernel.kallsyms] + 50.00% [k] kfunc1 + 15.00% [k] kfunc2 + 30.00% perf + 20.00% [.] foo + 10.00% [.] bar + 5.00% libc.so + 5.00% [.] libcall --overwrite:: Enable this to use just the most recent records, which helps in high core count diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ca8f2331795c..b16680d0f82c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1392,7 +1392,7 @@ int cmd_report(int argc, const char **argv) "only show processor socket that match with this filter"), OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace, "Show raw trace event output (do not use print fmt or plugins)"), - OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, + OPT_BOOLEAN('H', "hierarchy", &symbol_conf.report_hierarchy, "Show entries in a hierarchy"), OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", "'always' (default), 'never' or 'auto' only applicable to --stdio mode", diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index ea8c7eca5eee..3cccb2a516dc 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1573,7 +1573,7 @@ int cmd_top(int argc, const char **argv) "add last branch records to call history"), OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace, "Show raw trace event output (do not use print fmt or plugins)"), - OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, + OPT_BOOLEAN('H', "hierarchy", &symbol_conf.report_hierarchy, "Show entries in a hierarchy"), OPT_BOOLEAN(0, "overwrite", &top.record_opts.overwrite, "Use a backward ring buffer, default: no"),