From: Sean Christopherson <seanjc@google.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jim Mattson <jmattson@google.com>,
kvm@vger.kernel.org, Sandipan Das <sandipan.das@amd.com>
Subject: Re: [kvm-unit-tests PATCH v4 23/24] x86/pmu: Update testcases to cover AMD PMU
Date: Wed, 2 Nov 2022 17:58:38 +0000 [thread overview]
Message-ID: <Y2KvzqPsU5VIGU+x@google.com> (raw)
In-Reply-To: <20221024091223.42631-24-likexu@tencent.com>
On Mon, Oct 24, 2022, Like Xu wrote:
> @@ -104,11 +115,17 @@ static inline void write_gp_event_select(unsigned int i, u64 value)
>
> static inline u8 pmu_version(void)
> {
> + if (!is_intel())
> + return 0;
This can be handled by adding pmu_caps.version.
> +
> return cpuid_10.a & 0xff;
> }
>
> static inline bool this_cpu_has_pmu(void)
> {
> + if (!is_intel())
> + return true;
I think it makes sense to kill off this_cpu_has_pmu(), the only usage is after
an explicit is_intel() check, and practically speaking that will likely hold true
since differentiating between Intel and AMD PMUs seems inevitable.
> +
> return !!pmu_version();
> }
>
> @@ -135,12 +152,18 @@ static inline void set_nr_gp_counters(u8 new_num)
>
> static inline u8 pmu_gp_counter_width(void)
> {
> - return (cpuid_10.a >> 16) & 0xff;
> + if (is_intel())
Again, can be handled by utilizing pmu_caps.
> + return (cpuid_10.a >> 16) & 0xff;
> + else
> + return PMC_DEFAULT_WIDTH;
> }
>
> static inline u8 pmu_gp_counter_mask_length(void)
> {
> - return (cpuid_10.a >> 24) & 0xff;
> + if (is_intel())
> + return (cpuid_10.a >> 24) & 0xff;
> + else
> + return pmu_nr_gp_counters();
> }
>
> static inline u8 pmu_nr_fixed_counters(void)
> @@ -161,6 +184,9 @@ static inline u8 pmu_fixed_counter_width(void)
>
> static inline bool pmu_gp_counter_is_available(int i)
> {
> + if (!is_intel())
> + return i < pmu_nr_gp_counters();
> +
> /* CPUID.0xA.EBX bit is '1 if they counter is NOT available. */
> return !(cpuid_10.b & BIT(i));
> }
> @@ -268,4 +294,9 @@ static inline bool pebs_has_baseline(void)
> return pmu.perf_cap & PMU_CAP_PEBS_BASELINE;
> }
>
> +static inline bool has_amd_perfctr_core(void)
Unnecessary wrappers, just use this_cpu_has() directly.
> +{
> + return this_cpu_has(X86_FEATURE_PERFCTR_CORE);
> +}
next prev parent reply other threads:[~2022-11-02 17:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 9:11 [kvm-unit-tests PATCH v4 00/24] x86/pmu: Test case optimization, fixes and additions Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 01/24] x86/pmu: Add PDCM check before accessing PERF_CAP register Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 02/24] x86/pmu: Test emulation instructions on full-width counters Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 03/24] x86/pmu: Pop up FW prefix to avoid out-of-context propagation Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 04/24] x86/pmu: Report SKIP when testing Intel LBR on AMD platforms Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 05/24] x86/pmu: Fix printed messages for emulated instruction test Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 06/24] x86/pmu: Introduce __start_event() to drop all of the manual zeroing Like Xu
2022-11-02 17:41 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 07/24] x86/pmu: Introduce multiple_{one, many}() to improve readability Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 08/24] x86/pmu: Reset the expected count of the fixed counter 0 when i386 Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 09/24] x86: create pmu group for quick pmu-scope testing Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 10/24] x86/pmu: Refine info to clarify the current support Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 11/24] x86/pmu: Update rdpmc testcase to cover #GP path Like Xu
2022-11-02 17:42 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 12/24] x86/pmu: Rename PC_VECTOR to PMI_VECTOR for better readability Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 13/24] x86/pmu: Add lib/x86/pmu.[c.h] and move common code to header files Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 14/24] x86/pmu: Read cpuid(10) in the pmu_init() to reduce VM-Exit Like Xu
2022-11-02 17:45 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 15/24] x86/pmu: Initialize PMU perf_capabilities at pmu_init() Like Xu
2022-11-02 17:45 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 16/24] x86/pmu: Add GP counter related helpers Like Xu
2022-11-02 17:54 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 17/24] x86/pmu: Add GP/Fixed counters reset helpers Like Xu
2022-11-02 17:55 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 18/24] x86/pmu: Add a set of helpers related to global registers Like Xu
2022-11-02 17:56 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 19/24] x86: Add tests for Guest Processor Event Based Sampling (PEBS) Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 20/24] x86/pmu: Add global helpers to cover Intel Arch PMU Version 1 Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 21/24] x86/pmu: Add gp_events pointer to route different event tables Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 22/24] x86/pmu: Add nr_gp_counters to limit the number of test counters Like Xu
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 23/24] x86/pmu: Update testcases to cover AMD PMU Like Xu
2022-11-02 17:58 ` Sean Christopherson [this message]
2022-11-02 20:10 ` Sean Christopherson
2022-10-24 9:12 ` [kvm-unit-tests PATCH v4 24/24] x86/pmu: Add AMD Guest PerfMonV2 testcases Like Xu
2022-11-02 18:35 ` [kvm-unit-tests PATCH v4 00/24] x86/pmu: Test case optimization, fixes and additions 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=Y2KvzqPsU5VIGU+x@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=pbonzini@redhat.com \
--cc=sandipan.das@amd.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;
as well as URLs for NNTP newsgroup(s).