From: Mark Rutland <mark.rutland@arm.com>
To: "Rob Herring (Arm)" <robh@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
kvmarm@lists.linux.dev
Subject: Re: [PATCH 8/9] KVM: arm64: Refine PMU defines for number of counters
Date: Mon, 10 Jun 2024 12:27:07 +0100 [thread overview]
Message-ID: <ZmbjC9ILkHBIuCNI@J2N7QTR9R3> (raw)
In-Reply-To: <20240607-arm-pmu-3-9-icntr-v1-8-c7bd2dceff3b@kernel.org>
On Fri, Jun 07, 2024 at 02:31:33PM -0600, Rob Herring (Arm) wrote:
> There are 2 defines for the number of PMU counters:
> ARMV8_PMU_MAX_COUNTERS and ARMPMU_MAX_HWEVENTS. Both are the same
> currently, but Armv9.4/8.9 increases the number of possible counters
> from 32 to 33. With this change, the maximum number of counters will
> differ for KVM's PMU emulation which is PMUv3.4. Give KVM PMU emulation
> its own define to decouple it from the rest of the kernel's number PMU
> counters.
>
> The VHE PMU code needs to match the PMU driver, so switch it to use
> ARMPMU_MAX_HWEVENTS instead.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> arch/arm64/kvm/pmu-emul.c | 8 ++++----
> arch/arm64/kvm/pmu.c | 5 +++--
> include/kvm/arm_pmu.h | 3 ++-
> include/linux/perf/arm_pmuv3.h | 2 --
> 4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> index da5ba9d061e8..77fe79b2ba04 100644
> --- a/arch/arm64/kvm/pmu-emul.c
> +++ b/arch/arm64/kvm/pmu-emul.c
> @@ -234,7 +234,7 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
> int i;
> struct kvm_pmu *pmu = &vcpu->arch.pmu;
>
> - for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++)
> + for (i = 0; i < KVM_ARMV8_PMU_MAX_COUNTERS; i++)
> pmu->pmc[i].idx = i;
> }
>
> @@ -261,7 +261,7 @@ void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu)
> {
> int i;
>
> - for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++)
> + for (i = 0; i < KVM_ARMV8_PMU_MAX_COUNTERS; i++)
> kvm_pmu_release_perf_event(kvm_vcpu_idx_to_pmc(vcpu, i));
> irq_work_sync(&vcpu->arch.pmu.overflow_work);
> }
> @@ -292,7 +292,7 @@ void kvm_pmu_enable_counter_mask(struct kvm_vcpu *vcpu, u64 val)
> if (!(kvm_vcpu_read_pmcr(vcpu) & ARMV8_PMU_PMCR_E) || !val)
> return;
>
> - for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++) {
> + for (i = 0; i < KVM_ARMV8_PMU_MAX_COUNTERS; i++) {
> struct kvm_pmc *pmc;
>
> if (!(val & BIT(i)))
> @@ -324,7 +324,7 @@ void kvm_pmu_disable_counter_mask(struct kvm_vcpu *vcpu, u64 val)
> if (!kvm_vcpu_has_pmu(vcpu) || !val)
> return;
>
> - for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++) {
> + for (i = 0; i < KVM_ARMV8_PMU_MAX_COUNTERS; i++) {
> struct kvm_pmc *pmc;
>
> if (!(val & BIT(i)))
> diff --git a/arch/arm64/kvm/pmu.c b/arch/arm64/kvm/pmu.c
> index 01c9a9efdd1c..7eaf5f7aeae9 100644
> --- a/arch/arm64/kvm/pmu.c
> +++ b/arch/arm64/kvm/pmu.c
> @@ -5,6 +5,7 @@
> */
> #include <linux/kvm_host.h>
> #include <linux/perf_event.h>
> +#include <linux/perf/arm_pmu.h>
>
> #include <asm/arm_pmuv3.h>
>
> @@ -96,7 +97,7 @@ static void kvm_vcpu_pmu_enable_el0(unsigned long events)
> u64 typer;
> u32 counter;
>
> - for_each_set_bit(counter, &events, 32) {
> + for_each_set_bit(counter, &events, ARMPMU_MAX_HWEVENTS) {
> typer = kvm_vcpu_pmu_read_evtype_direct(counter);
> typer &= ~ARMV8_PMU_EXCLUDE_EL0;
> kvm_vcpu_pmu_write_evtype_direct(counter, typer);
> @@ -111,7 +112,7 @@ static void kvm_vcpu_pmu_disable_el0(unsigned long events)
> u64 typer;
> u32 counter;
>
> - for_each_set_bit(counter, &events, 32) {
> + for_each_set_bit(counter, &events, ARMPMU_MAX_HWEVENTS) {
> typer = kvm_vcpu_pmu_read_evtype_direct(counter);
> typer |= ARMV8_PMU_EXCLUDE_EL0;
> kvm_vcpu_pmu_write_evtype_direct(counter, typer);
> diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h
> index 871067fb2616..e08aeec5d936 100644
> --- a/include/kvm/arm_pmu.h
> +++ b/include/kvm/arm_pmu.h
> @@ -10,6 +10,7 @@
> #include <linux/perf_event.h>
> #include <linux/perf/arm_pmuv3.h>
>
> +#define KVM_ARMV8_PMU_MAX_COUNTERS 32
>
> #if IS_ENABLED(CONFIG_HW_PERF_EVENTS) && IS_ENABLED(CONFIG_KVM)
> struct kvm_pmc {
> @@ -25,7 +26,7 @@ struct kvm_pmu_events {
> struct kvm_pmu {
> struct irq_work overflow_work;
> struct kvm_pmu_events events;
> - struct kvm_pmc pmc[ARMV8_PMU_MAX_COUNTERS];
> + struct kvm_pmc pmc[KVM_ARMV8_PMU_MAX_COUNTERS];
> int irq_num;
> bool created;
> bool irq_level;
> diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h
> index caa09241ad4f..c902fe64f070 100644
> --- a/include/linux/perf/arm_pmuv3.h
> +++ b/include/linux/perf/arm_pmuv3.h
> @@ -6,8 +6,6 @@
> #ifndef __PERF_ARM_PMUV3_H
> #define __PERF_ARM_PMUV3_H
>
> -#define ARMV8_PMU_MAX_COUNTERS 32
> -
> /*
> * Common architectural and microarchitectural event numbers.
> */
>
> --
> 2.43.0
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-06-10 11:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 20:31 [PATCH 0/9] arm64: Add support for Armv9.4 PMU fixed instruction counter Rob Herring (Arm)
2024-06-07 20:31 ` [PATCH 1/9] perf/arm: Move 32-bit PMU drivers to drivers/perf/ Rob Herring (Arm)
2024-06-10 9:23 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 2/9] perf: arm_v6/7_pmu: Drop non-DT probe support Rob Herring (Arm)
2024-06-10 9:30 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 3/9] perf: arm_pmu: Remove event index to counter remapping Rob Herring (Arm)
2024-06-08 19:37 ` kernel test robot
2024-06-10 10:44 ` Mark Rutland
2024-06-10 16:42 ` Rob Herring
2024-06-07 20:31 ` [PATCH 4/9] perf: arm_pmuv3: Prepare for more than 32 counters Rob Herring (Arm)
2024-06-10 10:51 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 5/9] KVM: arm64: pmu: Use arm_pmuv3.h register accessors Rob Herring (Arm)
2024-06-10 11:02 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 6/9] KVM: arm64: pmu: Use generated define for PMSELR_EL0.SEL access Rob Herring (Arm)
2024-06-10 11:10 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 7/9] arm64: perf/kvm: Use a common PMU cycle counter define Rob Herring (Arm)
2024-06-10 11:24 ` Mark Rutland
2024-06-07 20:31 ` [PATCH 8/9] KVM: arm64: Refine PMU defines for number of counters Rob Herring (Arm)
2024-06-10 11:27 ` Mark Rutland [this message]
2024-06-07 20:31 ` [PATCH 9/9] perf: arm_pmuv3: Add support for Armv9.4 PMU instruction counter Rob Herring (Arm)
2024-06-10 11:55 ` Mark Rutland
2024-06-10 14:15 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZmbjC9ILkHBIuCNI@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=catalin.marinas@arm.com \
--cc=irogers@google.com \
--cc=james.morse@arm.com \
--cc=jolsa@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maz@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=peterz@infradead.org \
--cc=robh@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox