From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Shaoqin Huang" <shahuang@redhat.com>,
"Eric Auger" <eauger@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Laurent Vivier" <lvivier@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Sebastian Ott" <sebott@redhat.com>,
"Gavin Shan" <gshan@redhat.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-arm@nongnu.org,
"Zhenyu Wang" <zhenyu.z.wang@intel.com>,
"Dapeng Mi" <dapeng1.mi@intel.com>,
"Yuan Yao" <yuan.yao@intel.com>,
"Xiong Zhang" <xiong.y.zhang@intel.com>,
"Mingwei Zhang" <mizhang@google.com>,
"Jim Mattson" <jmattson@google.com>
Subject: Re: [RFC 3/5] i386/kvm: Support event with select&umask format in KVM PMU filter
Date: Tue, 23 Jul 2024 13:36:14 +0800 [thread overview]
Message-ID: <38231df8-81d7-4dd6-9ef9-a72fda228176@linux.intel.com> (raw)
In-Reply-To: <Zpomm3hLhSM5O6em@intel.com>
On 7/19/2024 4:40 PM, Zhao Liu wrote:
> Hi Dapeng,
>
> On Thu, Jul 18, 2024 at 01:28:25PM +0800, Mi, Dapeng wrote:
>
> [snip]
>
>>> + case KVM_PMU_EVENT_FMT_X86_DEFAULT: {
>>> + uint64_t select, umask;
>>> +
>>> + ret = qemu_strtou64(str_event->u.x86_default.select, NULL,
>>> + 0, &select);
>>> + if (ret < 0) {
>>> + error_setg(errp,
>>> + "Invalid %s PMU event (select: %s): %s. "
>>> + "The select must be a "
>>> + "12-bit unsigned number string.",
>>> + KVMPMUEventEncodeFmt_str(str_event->format),
>>> + str_event->u.x86_default.select,
>>> + strerror(-ret));
>>> + g_free(event);
>>> + goto fail;
>>> + }
>>> + if (select > UINT12_MAX) {
>>> + error_setg(errp,
>>> + "Invalid %s PMU event (select: %s): "
>>> + "Numerical result out of range. "
>>> + "The select must be a "
>>> + "12-bit unsigned number string.",
>>> + KVMPMUEventEncodeFmt_str(str_event->format),
>>> + str_event->u.x86_default.select);
>>> + g_free(event);
>>> + goto fail;
>>> + }
>>> + event->u.x86_default.select = select;
>>> +
>>> + ret = qemu_strtou64(str_event->u.x86_default.umask, NULL,
>>> + 0, &umask);
>>> + if (ret < 0) {
>>> + error_setg(errp,
>>> + "Invalid %s PMU event (umask: %s): %s. "
>>> + "The umask must be a uint8 string.",
>>> + KVMPMUEventEncodeFmt_str(str_event->format),
>>> + str_event->u.x86_default.umask,
>>> + strerror(-ret));
>>> + g_free(event);
>>> + goto fail;
>>> + }
>>> + if (umask > UINT8_MAX) {
>> umask is extended to 16 bits from Perfmon v6+. Please notice we need to
>> upgrade this to 16 bits in the future. More details can be found here.
>> [PATCH V3 00/13] Support Lunar Lake and Arrow Lake core PMU - kan.liang
>> (kernel.org)
>> <https://lore.kernel.org/all/20240626143545.480761-1-kan.liang@linux.intel.com/>
> It's tricky...now I referred the RAW_EVENT format in tools/testing/
> selftests/kvm/include/x86_64/pmu.h, which is used in KVM PMU and is
> compatible with AMD and Intel.
>
> The current KVM PMU filter for raw code doesn't define the layout in
> the standard API like masked entries (KVM_PMU_ENCODE_MASKED_ENTRY), but
> actually uses the RAW_EVENT format. So I even plan to move RAW_EVENT
> macro into arch/x86/include/uapi/asm/kvm.h...
For the raw event format, I suppose user should know the event layout and
would directly input the raw event code, qemu may not concern this.
>
> For the changes you mentioned, I think it would be better for the raw
> code layout design not to break RAW_EVENT, so that AMD and Intel can
> equally use the same macro to encode. Is it possible for a unified
> layout macro?
>
> What about extending RAW_EVENT as the following example? I understand
> the umask2 is at bit 40-47.
>
> #define X86_PMU_RAW_EVENT(eventsel, umask) (((eventsel & 0xf00UL) << 24) | \
> ((eventsel) & 0xff) | \
> ((umask) & 0xff) << 8) | \
> ((umask & 0xff00UL << 32)
It's always good if Intel and AMD can share same event layout, the extended
umask field occupies bits [40:47]. So I think we'd better follow this for
the RAW_EVENT as well.
>
> Thanks,
> Zhao
>
next prev parent reply other threads:[~2024-07-23 5:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 4:51 [RFC 0/5] accel/kvm: Support KVM PMU filter Zhao Liu
2024-07-10 4:51 ` [RFC 1/5] qapi/qom: Introduce kvm-pmu-filter object Zhao Liu
2024-07-10 4:51 ` [RFC 2/5] i386/kvm: Support initial KVM PMU filter Zhao Liu
2024-07-10 4:51 ` [RFC 3/5] i386/kvm: Support event with select&umask format in " Zhao Liu
2024-07-18 5:28 ` Mi, Dapeng
2024-07-19 8:40 ` Zhao Liu
2024-07-23 5:36 ` Mi, Dapeng [this message]
2024-07-10 4:51 ` [RFC 4/5] i386/kvm: Support event with masked entry " Zhao Liu
2024-07-10 4:51 ` [RFC 5/5] i386/kvm: Support fixed counter " Zhao Liu
2024-07-18 5:27 ` [RFC 0/5] accel/kvm: Support " Mi, Dapeng
2024-07-19 8:05 ` Zhao Liu
2024-08-02 9:01 ` Shaoqin Huang
2024-08-02 9:37 ` Zhao Liu
2024-08-02 9:41 ` Shaoqin Huang
2024-08-02 10:03 ` Zhao Liu
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=38231df8-81d7-4dd6-9ef9-a72fda228176@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dapeng1.mi@intel.com \
--cc=eauger@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=gshan@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=michael.roth@amd.com \
--cc=mizhang@google.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sebott@redhat.com \
--cc=shahuang@redhat.com \
--cc=thuth@redhat.com \
--cc=xiong.y.zhang@intel.com \
--cc=yuan.yao@intel.com \
--cc=zhao1.liu@intel.com \
--cc=zhenyu.z.wang@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;
as well as URLs for NNTP newsgroup(s).