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
Subject: Re: [kvm-unit-tests PATCH v4 16/24] x86/pmu: Add GP counter related helpers
Date: Wed, 2 Nov 2022 17:54:02 +0000 [thread overview]
Message-ID: <Y2Kuui/2op6aXbkJ@google.com> (raw)
In-Reply-To: <20221024091223.42631-17-likexu@tencent.com>
On Mon, Oct 24, 2022, Like Xu wrote:
+static inline u32 gp_counter_base(void)
> +{
> + return pmu.msr_gp_counter_base;
> +}
> +
> +static inline void set_gp_counter_base(u32 new_base)
> +{
> + pmu.msr_gp_counter_base = new_base;
> +}
> +
> +static inline u32 gp_event_select_base(void)
> +{
> + return pmu.msr_gp_event_select_base;
> +}
> +
> +static inline void set_gp_event_select_base(u32 new_base)
> +{
> + pmu.msr_gp_event_select_base = new_base;
> +}
> +
> +static inline u32 gp_counter_msr(unsigned int i)
> +{
> + return gp_counter_base() + i;
> +}
> +
> +static inline u32 gp_event_select_msr(unsigned int i)
As propsed in the previous version, I think it makes sense to make these look
like macros so that it's more obvious that the callers are computing an MSR index
and not getting the MSR, e.g.
MSR_GP_EVENT_SELECTx(i)
> +{
> + return gp_event_select_base() + i;
> +}
> +
> +static inline void write_gp_counter_value(unsigned int i, u64 value)
> +{
> + wrmsr(gp_counter_msr(i), value);
> +}
> +
> +static inline void write_gp_event_select(unsigned int i, u64 value)
> +{
> + wrmsr(gp_event_select_msr(i), value);
> +}
Almost all of these one-line wrappers are unnecessary. "struct pmu_caps pmu" is
already exposed, just reference "pmu" directly. And for the rdmsr/wrmsr wrappers,
the code I wanted to dedup was the calculation of the MSR index, hiding the actual
WRMSR and RDMSR operations are a net-negative IMO.
next prev parent reply other threads:[~2022-11-02 17:54 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 [this message]
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
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=Y2Kuui/2op6aXbkJ@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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.