Message ID | cover.1723518282.git.zhouquan@iscas.ac.cn |
---|---|
Headers | show
Return-Path: <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=x4xgKWiB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WjsXx51JTz1yXl for <incoming@patchwork.ozlabs.org>; Tue, 13 Aug 2024 23:23:59 +1000 (AEST) 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=7KsnC/A5ApHnFS00x24K9GbBLJDN3qjQijmC8ZQVdSc=; b=x4xgKWiBxtTwme 0fyXPR3L70TYyIBt9rC0ZgiaQbyTtCNzSjILXOU1dNuBx10DfQCkr2WqmGed3wj+31z9GMemKa/BX CgmskeIFhL1qTSM3Nx10k9QrnUcZKz4HAP5q2mu/qF7OW1PQqE6QvREwzAEjJgsX0DgV64eHoM0B2 gBnZHyvvj9itUzZ2eEdACDlckgaeKy7SekD067s1c0oOLZzVdOTHSIqNhNTk6RLPORjjyPJE+XIKN fhWUn0YisRHYIsiMYF7wb9uLaMdeJC5NmOAuAm8ZF54aUuucBYr3N+gy9u3SmHkdQnIl5n0ZJK57B QJDkjo4pnUkXLquDDbvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrVF-00000003qoL-0RsL; Tue, 13 Aug 2024 13:23:57 +0000 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrVA-00000003qnT-3ieJ; Tue, 13 Aug 2024 13:23:55 +0000 Received: from ThinkPad-T480s.. (unknown [121.237.44.107]) by APP-03 (Coremail) with SMTP id rQCowACHKRlVXrtm7WsLBg--.54503S2; Tue, 13 Aug 2024 21:23:34 +0800 (CST) From: zhouquan@iscas.ac.cn To: anup@brainfault.org, ajones@ventanamicro.com, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-perf-users@vger.kernel.org, Quan Zhou <zhouquan@iscas.ac.cn> Subject: [PATCH v2 0/2] riscv: Add perf support to collect KVM guest statistics from host side Date: Tue, 13 Aug 2024 21:23:33 +0800 Message-Id: <cover.1723518282.git.zhouquan@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: rQCowACHKRlVXrtm7WsLBg--.54503S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJw17AFy7Gr4UGF1rCr1xKrg_yoWrKF1Dpr 43Cr43tF4rAryIqw1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/1tbiBwwIBma7QjdI8QAAsU X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_062353_318842_96E2366C X-CRM114-Status: UNSURE ( 7.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Quan Zhou <zhouquan@iscas.ac.cn> Add basic guest support to RISC-V perf, enabling it to distinguish whether PMU interrupts occur in the host or the guest, and then collect some basic guest information from the host side (guest os cal [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in bl.score.senderscore.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <kvm-riscv.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/kvm-riscv>, <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/kvm-riscv/> List-Post: <mailto:kvm-riscv@lists.infradead.org> List-Help: <mailto:kvm-riscv-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/kvm-riscv>, <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kvm-riscv" <kvm-riscv-bounces@lists.infradead.org> Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org |
Series |
riscv: Add perf support to collect KVM guest statistics from host side
|
expand
|
From: Quan Zhou <zhouquan@iscas.ac.cn> Add basic guest support to RISC-V perf, enabling it to distinguish whether PMU interrupts occur in the host or the guest, and then collect some basic guest information from the host side (guest os callchain is not supported for now). Based on the x86/arm implementation, tested with kvm-riscv. test env: - host: qemu-9.0.0 - guest: qemu-9.0.0 --enable-kvm (only start one guest and run top) ----------------------------------------- 1) perf kvm top ./perf kvm --host --guest \ --guestkallsyms=/root/repo/shared/kallsyms \ --guestmodules=/root/repo/shared/modules top PerfTop: 41 irqs/sec kernel:97.6% us: 0.0% guest kernel: 0.0% guest us: 0.0% exact: 0.0% [250Hz cycles:P], (all, 4 CPUs) ------------------------------------------------------------------------------- 64.57% [kernel] [k] default_idle_call 3.12% [kernel] [k] _raw_spin_unlock_irqrestore 3.03% [guest.kernel] [g] mem_serial_out 2.61% [kernel] [k] handle_softirqs 2.32% [kernel] [k] do_trap_ecall_u 1.71% [kernel] [k] _raw_spin_unlock_irq 1.26% [guest.kernel] [g] do_raw_spin_lock 1.25% [kernel] [k] finish_task_switch.isra.0 1.16% [kernel] [k] do_idle 0.77% libc.so.6 [.] ioctl 0.76% [kernel] [k] queue_work_on 0.69% [kernel] [k] __local_bh_enable_ip 0.67% [guest.kernel] [g] __noinstr_text_start 0.64% [guest.kernel] [g] mem_serial_in 0.41% libc.so.6 [.] pthread_sigmask 0.39% [kernel] [k] mem_cgroup_uncharge_skmem 0.39% [kernel] [k] __might_resched 0.39% [guest.kernel] [g] _nohz_idle_balance.isra.0 0.37% [kernel] [k] sched_balance_update_blocked_averages 0.34% [kernel] [k] sched_balance_rq 2) perf kvm record ./perf kvm --host --guest \ --guestkallsyms=/root/repo/shared/kallsyms \ --guestmodules=/root/repo/shared/modules record -a sleep 60 [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 1.292 MB perf.data.kvm (17990 samples) ] 3) perf kvm report (the data shown here is not complete) ./perf kvm --host --guest \ --guestkallsyms=/root/repo/shared/kallsyms \ --guestmodules=/root/repo/shared/modules report -i perf.data.kvm # Total Lost Samples: 0 # # Samples: 17K of event 'cycles:P' # Event count (approx.): 269968947184 # # Overhead Command Shared Object Symbol # ........ ............... ....................... .............................................. # 61.86% swapper [kernel.kallsyms] [k] default_idle_call 2.93% :6463 [guest.kernel.kallsyms] [g] do_raw_spin_lock 2.82% :6462 [guest.kernel.kallsyms] [g] mem_serial_out 2.11% sshd [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore 1.78% :6462 [guest.kernel.kallsyms] [g] do_raw_spin_lock 1.37% swapper [kernel.kallsyms] [k] handle_softirqs 1.36% swapper [kernel.kallsyms] [k] do_idle 1.21% sshd [kernel.kallsyms] [k] do_trap_ecall_u 1.21% sshd [kernel.kallsyms] [k] _raw_spin_unlock_irq 1.11% qemu-system-ris [kernel.kallsyms] [k] do_trap_ecall_u 0.93% qemu-system-ris libc.so.6 [.] ioctl 0.89% sshd [kernel.kallsyms] [k] __local_bh_enable_ip 0.77% qemu-system-ris [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore 0.68% qemu-system-ris [kernel.kallsyms] [k] queue_work_on 0.65% sshd [kernel.kallsyms] [k] handle_softirqs 0.44% :6462 [guest.kernel.kallsyms] [g] mem_serial_in 0.42% sshd libc.so.6 [.] pthread_sigmask 0.34% :6462 [guest.kernel.kallsyms] [g] serial8250_tx_chars 0.30% swapper [kernel.kallsyms] [k] finish_task_switch.isra.0 0.29% swapper [kernel.kallsyms] [k] sched_balance_rq 0.29% sshd [kernel.kallsyms] [k] __might_resched 0.26% swapper [kernel.kallsyms] [k] tick_nohz_idle_exit 0.26% swapper [kernel.kallsyms] [k] sched_balance_update_blocked_averages 0.26% swapper [kernel.kallsyms] [k] _nohz_idle_balance.isra.0 0.24% qemu-system-ris [kernel.kallsyms] [k] finish_task_switch.isra.0 0.23% :6462 [guest.kernel.kallsyms] [g] __noinstr_text_start --- Change since v1: - Rebased on v6.11-rc3 - Fix incorrect misc type (Andrew) --- v1 link: https://lore.kernel.org/all/cover.1721271251.git.zhouquan@iscas.ac.cn/ Quan Zhou (2): riscv: perf: add guest vs host distinction riscv: KVM: add basic support for host vs guest profiling arch/riscv/include/asm/kvm_host.h | 5 ++++ arch/riscv/include/asm/perf_event.h | 7 ++++++ arch/riscv/kernel/perf_callchain.c | 38 +++++++++++++++++++++++++++++ arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/main.c | 12 +++++++-- arch/riscv/kvm/vcpu.c | 7 ++++++ 6 files changed, 68 insertions(+), 2 deletions(-) base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba