[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85286356-8005-8a4d-927c-c3d70c723161@redhat.com>
Date: Thu, 18 Nov 2021 16:00:03 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Like Xu <like.xu.linux@...il.com>,
Jim Mattson <jmattson@...gle.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] KVM: x86/pmu: Reuse find_perf_hw_id() and drop
find_fixed_event()
On 11/16/21 13:20, Like Xu wrote:
> +static inline unsigned int intel_find_fixed_event(int idx)
> +{
> + u32 event;
> + size_t size = ARRAY_SIZE(fixed_pmc_events);
> +
> + if (idx >= size)
> + return PERF_COUNT_HW_MAX;
> +
> + event = fixed_pmc_events[array_index_nospec(idx, size)];
> + return intel_arch_events[event].event_type;
> +}
> +
> +
> static unsigned int intel_find_perf_hw_id(struct kvm_pmc *pmc)
> {
> struct kvm_pmu *pmu = pmc_to_pmu(pmc);
> @@ -75,6 +88,9 @@ static unsigned int intel_find_perf_hw_id(struct kvm_pmc *pmc)
> u8 unit_mask = (pmc->eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
> int i;
>
> + if (pmc_is_fixed(pmc))
> + return intel_find_fixed_event(pmc->idx - INTEL_PMC_IDX_FIXED);
Is intel_find_fixed_event needed at all? As you point out in the commit
message, eventsel/unit_mask are valid so you can do
@@ -88,13 +75,11 @@ static unsigned int intel_pmc_perf_hw_id(struct kvm_pmc *pmc)
u8 unit_mask = (pmc->eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
int i;
- if (pmc_is_fixed(pmc))
- return intel_find_fixed_event(pmc->idx - INTEL_PMC_IDX_FIXED);
-
for (i = 0; i < ARRAY_SIZE(intel_arch_events); i++)
if (intel_arch_events[i].eventsel == event_select
&& intel_arch_events[i].unit_mask == unit_mask
- && (pmu->available_event_types & (1 << i)))
+ && (pmc_is_fixed(pmc) ||
+ pmu->available_event_types & (1 << i)))
break;
if (i == ARRAY_SIZE(intel_arch_events))
What do you think? It's less efficient but makes fixed/gp more similar.
Can you please resubmit the series based on the review feedback?
Thanks,
Powered by blists - more mailing lists