From: Like Xu <like.xu.linux@gmail.com>
To: Jim Mattson <jmattson@google.com>, Ravi Bangoria <ravi.bangoria@amd.com>
Cc: seanjc@google.com, dave.hansen@linux.intel.com,
peterz@infradead.org, alexander.shishkin@linux.intel.com,
eranian@google.com, daviddunn@google.com, ak@linux.intel.com,
kan.liang@linux.intel.com, x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, kim.phillips@amd.com,
santosh.shukla@amd.com,
"Paolo Bonzini - Distinguished Engineer (kernel-recipes.org)
(KVM HoF)" <pbonzini@redhat.com>
Subject: Re: [PATCH 3/3] KVM: x86/pmu: Segregate Intel and AMD specific logic
Date: Fri, 4 Mar 2022 17:33:47 +0800 [thread overview]
Message-ID: <e1dd4d82-b5d8-fdae-325b-75ba690eaf2e@gmail.com> (raw)
In-Reply-To: <CALMp9eTTpdtsEek17-EnSZu53-+LmwcSTYmou1+u34LdT3TMmQ@mail.gmail.com>
On 4/3/2022 2:05 am, Jim Mattson wrote:
> On Thu, Mar 3, 2022 at 8:25 AM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>>
>>
>>
>> On 03-Mar-22 10:08 AM, Jim Mattson wrote:
>>> On Mon, Feb 21, 2022 at 2:02 AM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>>>>
>>>>
>>>>
>>>> On 21-Feb-22 1:27 PM, Like Xu wrote:
>>>>> On 21/2/2022 3:31 pm, Ravi Bangoria wrote:
>>>>>> void reprogram_counter(struct kvm_pmu *pmu, int pmc_idx)
>>>>>> {
>>>>>> struct kvm_pmc *pmc = kvm_x86_ops.pmu_ops->pmc_idx_to_pmc(pmu, pmc_idx);
>>>>>> + bool is_intel = !strncmp(kvm_x86_ops.name, "kvm_intel", 9);
>>>>>
>>>>> How about using guest_cpuid_is_intel(vcpu)
>>>>
>>>> Yeah, that's better then strncmp().
>>>>
>>>>> directly in the reprogram_gp_counter() ?
>>>>
>>>> We need this flag in reprogram_fixed_counter() as well.
>>>
>>> Explicit "is_intel" checks in any form seem clumsy,
>>
>> Indeed. However introducing arch specific callback for such tiny
>> logic seemed overkill to me. So thought to just do it this way.
>
> I agree that arch-specific callbacks are ridiculous for these distinctions.
>
>>> since we have
>>> already put some effort into abstracting away the implementation
>>> differences in struct kvm_pmu. It seems like these differences could
>>> be handled by adding three masks to that structure: the "raw event
>>> mask" (i.e. event selector and unit mask), the hsw_in_tx mask, and the
>>> hsw_in_tx_checkpointed mask.
>>
>> struct kvm_pmu is arch independent. You mean struct kvm_pmu_ops?
>
> No; I meant exactly what I said. See, for example, how the
> reserved_bits field is used. It is initialized in the vendor-specific
> pmu_refresh functions, and from then on, it facilitates
> vendor-specific behaviors without explicit checks or vendor-specific
> callbacks. An eventsel_mask field would be a natural addition to this
> structure, to deal with the vendor-specific event selector widths. The
> hsw_in_tx_mask and hsw_in_tx_checkpointed_mask fields are less
> natural, since they will be 0 on AMD, but they would make it simple to
> write the corresponding code in a vendor-neutral fashion.
>
> BTW, am I the only one who finds the HSW_ prefixes a bit absurd here,
> since TSX was never functional on Haswell?
The TSX story has more twists and turns, but we may start with 3a632cb229bf.
>
>>>
>>> These changes should also be coordinated with Like's series that
>>> eliminates all of the PERF_TYPE_HARDWARE nonsense.
>>
>> I'll rebase this on Like's patch series.
I could take over 3nd patch w/ Co-developed-by and move on if Ravi agrees.
>
> That's not exactly what I meant, but okay.
next prev parent reply other threads:[~2022-03-04 9:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 7:31 [PATCH 0/3] KVM: x86/pmu: Segregate Intel and AMD specific logic Ravi Bangoria
2022-02-21 7:31 ` [PATCH 1/3] x86/pmu: Add INTEL_ prefix in some Intel specific macros Ravi Bangoria
2022-02-21 7:31 ` [PATCH 2/3] x86/pmu: Replace X86_ALL_EVENT_FLAGS with INTEL_ALL_EVENT_FLAGS Ravi Bangoria
2022-02-21 7:31 ` [PATCH 3/3] KVM: x86/pmu: Segregate Intel and AMD specific logic Ravi Bangoria
2022-02-21 7:57 ` Like Xu
2022-02-21 10:01 ` Ravi Bangoria
2022-03-03 4:38 ` Jim Mattson
2022-03-03 16:25 ` Ravi Bangoria
2022-03-03 18:05 ` Jim Mattson
2022-03-04 9:33 ` Like Xu [this message]
2022-03-05 3:29 ` Ravi Bangoria
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=e1dd4d82-b5d8-fdae-325b-75ba690eaf2e@gmail.com \
--to=like.xu.linux@gmail.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=daviddunn@google.com \
--cc=eranian@google.com \
--cc=jmattson@google.com \
--cc=kan.liang@linux.intel.com \
--cc=kim.phillips@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=santosh.shukla@amd.com \
--cc=seanjc@google.com \
--cc=x86@kernel.org \
/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