From: Sandipan Das <sandipan.das@amd.com>
To: Dapeng Mi <dapeng1.mi@linux.intel.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jim Mattson <jmattson@google.com>,
Mingwei Zhang <mizhang@google.com>,
Zide Chen <zide.chen@intel.com>,
Shukla Manali <Manali.Shukla@amd.com>,
Dapeng Mi <dapeng1.mi@intel.com>
Subject: Re: [kvm-unit-tests PATCH] x86/pmu: Verify all available GP counters in check_counters_many()
Date: Thu, 12 Jun 2025 13:05:30 +0530 [thread overview]
Message-ID: <d00a02f8-2ebe-4952-8dc8-abf722f2af65@amd.com> (raw)
In-Reply-To: <20250611075842.20959-1-dapeng1.mi@linux.intel.com>
On 6/11/2025 1:28 PM, Dapeng Mi wrote:
> The intent of check_counters_many() is to verify all available counters
> can count correctly at the same time. So an alternative event should be
> picked to verify the avaialbe GP counter instead of skiping the counter
> if the initial event is not available.
>
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> ---
> Please notice this patch is based on Sean's "x86: Add CPUID properties,
> clean up related code" v2 patchset (https://lore.kernel.org/all/20250610195415.115404-1-seanjc@google.com/).
>
> x86/pmu.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
For AMD processors
Tested-by: Sandipan Das <sandipan.das@amd.com>
> diff --git a/x86/pmu.c b/x86/pmu.c
> index 3987311c..a6b0cfcc 100644
> --- a/x86/pmu.c
> +++ b/x86/pmu.c
> @@ -457,18 +457,34 @@ static void check_fixed_counters(void)
> }
> }
>
> +static struct pmu_event *get_one_event(int idx)
> +{
> + int i;
> +
> + if (pmu_arch_event_is_available(idx))
> + return &gp_events[idx % gp_events_size];
> +
> + for (i = 0; i < gp_events_size; i++) {
> + if (pmu_arch_event_is_available(i))
> + return &gp_events[i];
> + }
> +
> + return NULL;
> +}
> +
> static void check_counters_many(void)
> {
> + struct pmu_event *evt;
> pmu_counter_t cnt[48];
> int i, n;
>
> for (i = 0, n = 0; n < pmu.nr_gp_counters; i++) {
> - if (!pmu_arch_event_is_available(i))
> + evt = get_one_event(i);
> + if (!evt)
> continue;
>
> cnt[n].ctr = MSR_GP_COUNTERx(n);
> - cnt[n].config = EVNTSEL_OS | EVNTSEL_USR |
> - gp_events[i % gp_events_size].unit_sel;
> + cnt[n].config = EVNTSEL_OS | EVNTSEL_USR | evt->unit_sel;
> n++;
> }
> for (i = 0; i < fixed_counters_num; i++) {
next prev parent reply other threads:[~2025-06-12 7:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 7:58 [kvm-unit-tests PATCH] x86/pmu: Verify all available GP counters in check_counters_many() Dapeng Mi
2025-06-12 7:35 ` Sandipan Das [this message]
2025-06-25 22:25 ` Sean Christopherson
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=d00a02f8-2ebe-4952-8dc8-abf722f2af65@amd.com \
--to=sandipan.das@amd.com \
--cc=Manali.Shukla@amd.com \
--cc=dapeng1.mi@intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=zide.chen@intel.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