From patchwork Mon Mar 13 11:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13172301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EAA5C6FD19 for ; Mon, 13 Mar 2023 11:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tBiZuczPgmT7XIcX6JtXuqUoZnVnQ+HhttW6idNI5Xo=; b=oNp2Y7QRIjTTLz KdpfkZe23M65BUC1Bqj+mRlUj+sk4ZsNIO0oI1OO6mxIouDfi5Y1s8n7G4iDPXyPZwkcYIkDNfEz7 OM1MyVKd6mKeZ60dKXr7itmmbzylry+eIdjE3WJVbYCuVnjsaLCgD3mb4lTDpthitCm7k9hJVg2wK QofC2mufLlMZw0UpTFk+nH10W66uDXreg12Kbk2BgYpkidPGjKAGryfaE4ODuKaYZxUSdKls+Z52k TLxaJECLNmYoS6PTQ70ox9xylRqmKEOT91WnLW+dRTUenlGtCgnDPs200J/Axhsxb8smu8SQh8ax7 JV/ogXzg/UIuxThovBYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbgXj-005RzX-V3; Mon, 13 Mar 2023 11:40:44 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbgXg-005Ry6-Hy for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 11:40:42 +0000 Received: by mail-pl1-x630.google.com with SMTP id p20so12551627plw.13 for ; Mon, 13 Mar 2023 04:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678707637; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0EAtvo1So/zPFTCpyYhVNyCZVLKaC2sgLkHS7h4c9HI=; b=X1KDjnPYBYAadbBiCgglFFKeQZxJ/PEdNiBAUYNkojjh67qEA65iUTnBjaB2AvaE+l fy2jSsu8P5/IBXSYWxxFDFfRgSmgwP0kq43Wyh3I4nCyf1l7WtkKT74/DvQMM9qQ17j+ ccUC1l3yk5usFBDWHYBB2Yo/DfliCEaec4XA3ECBOqJoRZRlILI+X0LAHcUfnfEQ+pE1 P3Ef718VCS/mRIadlud9RVl6nO+OuRjfQ7DFfCXPg0cSge5Rtj7RfKZuO8qdHlOAFlFp 6P2ERambOtJhrCBAKhC0XXE/XPL5ypnCiIh2bbhXwq1hLh5d+0bRrAci+UDeD7q7oYDw DLhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678707637; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0EAtvo1So/zPFTCpyYhVNyCZVLKaC2sgLkHS7h4c9HI=; b=Nan7hvXqiTOg2mQh+n+fesPUZfQ/h85yEmJ3oHoJmpEDd+EKA1RouLM85LvU5jnBTZ BevDuB3uCSfC8rYiz1ttEDImRQ1EG1+uuHG4k3Z+an353K9tJ/jIGbVbJQQB8jJf/2cP 9rxPFGZ3Y7Rg3fwCUPAy3MBYifwWDwMnKC1R50a+xh6ru73LuYB3P5pdM1edL0p5NxhO yo8VzXyIE//6nHVpRR2WsQh2/SsIB5bdytwjfbhGlTwyshP5B6Yw+IcfbFyCz9l8LpIJ RXM/5VK9CBMBZ/oKlTFeGa0qk8JBFM2YcT6k/kUdvun7djt+vOjcEhnJDpAbJvFEE/MI fLGw== X-Gm-Message-State: AO0yUKXYuhJzj689Clx+loEfnjc3Be7M4H8yJ4OIiLryuUFi80VKbFik 3uYSOgdLPy9JHnxhnjy1mJuCDQ== X-Google-Smtp-Source: AK7set9socWh1UG+jyBtropg1WjPePnuqA3jmkI1RbgqzI8RMELBbwR9dWUiGkRWFsQfGBlVQ4/tLw== X-Received: by 2002:a17:90a:b89:b0:23b:5537:8c99 with SMTP id 9-20020a17090a0b8900b0023b55378c99mr4477602pjr.45.1678707636603; Mon, 13 Mar 2023 04:40:36 -0700 (PDT) Received: from leoy-huanghe.lan ([156.59.236.112]) by smtp.gmail.com with ESMTPSA id q21-20020a17090a2e1500b0022335f1dae2sm4281625pjd.22.2023.03.13.04.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 04:40:36 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , John Garry , James Clark , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 00/16] perf kvm: Support histograms and TUI mode Date: Mon, 13 Mar 2023 19:40:02 +0800 Message-Id: <20230313114018.543254-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_044040_626105_8E2DFA30 X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch set is to enable histograms and (partially) TUI mode in perf kvm tool. Patch set v1 [1] gives brief introduction for the change and this series has a minor update for the patch 13 'perf kvm: Add TUI mode for stat report' to avoid building failure when the system doesn't support HAVE_SLANG_SUPPORT. We can use below commands for testing this series: In a terminal, you could launch a virtual machine with qemu command; in below case, I downloaded a Ubuntu (or Debian) iso file and used it as the file system image: $ qemu-system-x86_64 -M pc -enable-kvm -cpu host -m 4096 -hda ubuntu-22.04-desktop-amd64.iso Then in another terminal, I can use below command to capture KVM trace data and report the result: # cd linux/tools/perf # ./perf kvm stat record # ./perf kvm stat report => Output in TUI mode # ./perf kvm stat report --stdio => Output in stdio mode Changes from v3: * Updated patch 04 to change comparison function return type from int to int64_t to avoid overflow; * Added a refactoring patch 05 "perf kvm: Use macro to replace variable 'decode_str_len'"; * Refined to use hists__add_entry_ops() and hist_entry__cmp() to compare hist entry and add new entries, to support comparison between hist entry, added a new patch 09; (Namhyung Kim) * Updated patch 10 for comparison event name; (Namhyung Kim) * Refined patch 11 to move init_stats() and hists__inc_nr_samples() into kvm_he_zalloc(); (Namhyung Kim) * Minor refactoring for sort_result() and kvm_hists__init() in patch 15. Changes from v2: * Found building failure with command 'make VF=1 DEBUG=1 NO_SLANG=1', fixed it in the patch 13. (James Clark) Changes from v1: * Updated the patch 13 'perf kvm: Add TUI mode for stat report' to avoid building failure if no support HAVE_SLANG_SUPPORT. [1] https://lore.kernel.org/lkml/20230226042053.1492409-1-leo.yan@linaro.org/ Leo Yan (16): perf kvm: Refactor overall statistics perf kvm: Add pointer to 'perf_kvm_stat' in kvm event perf kvm: Move up metrics helpers perf kvm: Use subtraction for comparison metrics perf kvm: Use macro to replace variable 'decode_str_len' perf kvm: Introduce histograms data structures perf kvm: Pass argument 'sample' to kvm_alloc_init_event() perf kvm: Parse address location for samples perf hist: Add 'kvm_info' field in histograms entry perf kvm: Add dimensions for KVM event statistics perf kvm: Use histograms list to replace cached list perf kvm: Polish sorting key perf kvm: Support printing attributions for dimensions perf kvm: Add dimensions for percentages perf kvm: Add TUI mode for stat report perf kvm: Update documentation to reflect new changes tools/perf/Documentation/perf-kvm.txt | 9 +- tools/perf/arch/arm64/util/kvm-stat.c | 1 - tools/perf/arch/powerpc/util/kvm-stat.c | 3 +- tools/perf/arch/s390/util/kvm-stat.c | 1 - tools/perf/arch/x86/util/kvm-stat.c | 7 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 4 +- tools/perf/builtin-diff.c | 4 +- tools/perf/builtin-kvm.c | 859 +++++++++++++++++++----- tools/perf/tests/hists_link.c | 4 +- tools/perf/util/hist.c | 19 +- tools/perf/util/hist.h | 3 + tools/perf/util/kvm-stat.h | 33 +- tools/perf/util/sort.h | 1 + 14 files changed, 745 insertions(+), 205 deletions(-)