From patchwork Mon Nov 15 16:56:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 12692635 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E06EC433F5 for ; Mon, 15 Nov 2021 16:56:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4008C60174 for ; Mon, 15 Nov 2021 16:56:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4008C60174 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=7H0GuM5jOue5wMyDmtKHsIl7h1j67QHSeLLJxnlDAms=; b=JUlJOe1n2DFWEn /F2sPKlBViA6sGEF42fCip9NyFdXCYVEsz4vS9ZX33T744q16KYj/z10VmcDWmZUpUT/oKS2yP3x0 AkRfrWFmRAxKuGcL4qrup4nGmgFVmEzmFOau7xGieF0cBeZRhcYVDA48mvVM/Gv4avBRkS6fsy5Yt aGKgbN6+OFwQyeN4tc2XWHpRdONXWCjKKuFliSlHJJ/Iysx/kPEsxExvRDElB45CWlfXzFhgi4gwe OepyhqbalFH92BlwqwmHFwGZrw1xJRD4KaZMEUJHnSRctEuhosh7L/EZqfN5h+ihXkMQ8sQpjKuaz 6MB0BAiK9iSAMHoFvf0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmfGV-00GQZc-Bl; Mon, 15 Nov 2021 16:55:31 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmfGQ-00GQY6-AC for linux-arm-kernel@lists.infradead.org; Mon, 15 Nov 2021 16:55:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4532F1FB; Mon, 15 Nov 2021 08:55:25 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2F7C3F766; Mon, 15 Nov 2021 08:55:23 -0800 (PST) From: Alexandru Elisei To: will@kernel.org, julien.thierry.kdev@gmail.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com Subject: [PATCH kvmtool 0/9] arm64: Improve PMU support on heterogeneous systems Date: Mon, 15 Nov 2021 16:56:56 +0000 Message-Id: <20211115165705.195736-1-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211115_085526_469105_FDCA7E29 X-CRM114-Status: GOOD ( 21.10 ) 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 The series can be found at [1], and the Linux patches that this series is based on at [2]. The series adds support for the KVM_ARM_VCPU_PMU_V3_SET_PMU PMU attribute, which allows userspace to set a PMU for a VCPU. This PMU is used by KVM when creating perf events to emulate the guest PMU. Without settings this attribute, the PMU used when creating events is the first one that successfully probed when booting, but this is unreliable as the probe order can change (if the order of the PMUs is changed in the DTB or if asynchronous driver probing is enabled at the host's command line), and furthermore it requires the user to have intimate knowledge of how the PMU was chosen in order to pin the VM on the correct physical CPUs. With KVM_ARM_VCPU_PMU_V3_SET_PMU, the user is still expected to pin the VM on a particular set of CPUs, but now it can be any CPUs as long as they share the same PMU. The set does not depend anymore on the driver probe order and all that is necessary for the user to know is which CPUs are the little core and which are the big cores, in a big.little configuration, which I believe is more reasonable. Patches #1-#5 move the PMU code to aarch64, where it belongs, because the PMU has never been supported on KVM for arm. This also paves the way for pulling in the KVM_ARM_VCPU_PMU_V3_SET_PMU attribute, which was not defined for KVM for arm (when KVM supported arm). This can be merged right now, independently of the other patches. Patches #6-#7 add the function cpulist_parse(), copied almost as-is from Linux v5.15. Patch #8 pulls all the necessary user API definitions, and finally patch #9 adds support for KVM_ARM_VCPU_PMU_V3_SET_PMU. [1] https://gitlab.arm.com/linux-arm/kvmtool-ae/-/tree/pmu-big-little-fix-v1 [2] https://gitlab.arm.com/linux-arm/linux-ae/-/tree/pmu-big-little-fix-v1 Alexandru Elisei (9): linux/err.h: Add missing stdbool.h include arm: Move arch specific VCPU features to the arch specific function arm: Get rid of the ARM_VCPU_FEATURE_FLAGS() macro arm: Make the PMUv3 emulation code arm64 specific arm64: Rework set_pmu_attr() util: Add basic cpumask functions util: Add cpulist_parse() update_headers.sh: Sync headers with Linux v5.16-rc1 + SET_PMU attribute arm64: Add support for KVM_ARM_VCPU_PMU_V3_SET_PMU Makefile | 5 +- arm/aarch32/include/asm/kernel.h | 8 + arm/aarch32/include/kvm/kvm-cpu-arch.h | 4 - arm/aarch64/arm-cpu.c | 3 +- arm/aarch64/include/asm/kernel.h | 8 + arm/aarch64/include/asm/kvm.h | 57 ++- .../arm-common => aarch64/include/asm}/pmu.h | 0 arm/aarch64/include/kvm/kvm-cpu-arch.h | 6 - arm/aarch64/kvm-cpu.c | 12 + arm/aarch64/pmu.c | 201 ++++++++ arm/kvm-cpu.c | 14 +- arm/pmu.c | 76 --- include/linux/bitmap.h | 45 ++ include/linux/bitops.h | 2 + include/linux/cpumask.h | 38 ++ include/linux/err.h | 2 + include/linux/kernel.h | 3 + include/linux/kvm.h | 441 +++++++++++++++++- mips/include/asm/kernel.h | 8 + powerpc/include/asm/kernel.h | 8 + powerpc/include/asm/kvm.h | 10 + util/bitmap.c | 221 +++++++++ x86/include/asm/kernel.h | 8 + x86/include/asm/kvm.h | 64 ++- 24 files changed, 1132 insertions(+), 112 deletions(-) create mode 100644 arm/aarch32/include/asm/kernel.h create mode 100644 arm/aarch64/include/asm/kernel.h rename arm/{include/arm-common => aarch64/include/asm}/pmu.h (100%) create mode 100644 arm/aarch64/pmu.c delete mode 100644 arm/pmu.c create mode 100644 include/linux/bitmap.h create mode 100644 include/linux/cpumask.h create mode 100644 mips/include/asm/kernel.h create mode 100644 powerpc/include/asm/kernel.h create mode 100644 util/bitmap.c create mode 100644 x86/include/asm/kernel.h