From: Dongli Zhang <dongli.zhang@oracle.com>
To: kan.liang@linux.intel.com, peterz@infradead.org,
mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org
Cc: alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, joe.jin@oracle.com, likexu@tencent.com
Subject: Re: [PATCH] perf/x86/intel: Hide Topdown metrics events if slots is not enumerated
Date: Sun, 9 Oct 2022 22:03:40 -0700 [thread overview]
Message-ID: <91d8d712-f20b-0809-7272-9b16bf83968d@oracle.com> (raw)
In-Reply-To: <20220922201505.2721654-1-kan.liang@linux.intel.com>
Ping?
Currently the default "perf stat" may fail on all Icelake KVM VMs.
Thank you very much!
Dongli Zhang
On 9/22/22 13:15, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
>
> The below error is observed on Ice Lake VM.
>
> $ perf stat
> Error:
> The sys_perf_event_open() syscall returned with 22 (Invalid argument)
> for event (slots).
> /bin/dmesg | grep -i perf may provide additional information.
>
> In a virtualization env, the Topdown metrics and the slots event haven't
> been supported yet. The guest CPUID doesn't enumerate them. However, the
> current kernel unconditionally exposes the slots event and the Topdown
> metrics events to sysfs, which misleads the perf tool and triggers the
> error.
>
> Hide the perf metrics topdown events and the slots event if the slots
> event is not enumerated.
>
> The big core of a hybrid platform can also supports the perf-metrics
> feature. Fix the hybrid platform as well.
>
> Reported-by: Dongli Zhang <dongli.zhang@oracle.com>
> Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
> arch/x86/events/intel/core.c | 33 ++++++++++++++++++++++++++++++++-
> 1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index b16c91ac9219..a0a62b67c440 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -5335,6 +5335,19 @@ static struct attribute *intel_pmu_attrs[] = {
> NULL,
> };
>
> +static umode_t
> +td_is_visible(struct kobject *kobj, struct attribute *attr, int i)
> +{
> + /*
> + * Hide the perf metrics topdown events
> + * if the slots is not enumerated.
> + */
> + if (x86_pmu.num_topdown_events)
> + return (x86_pmu.intel_ctrl & INTEL_PMC_MSK_FIXED_SLOTS) ? attr->mode : 0;
> +
> + return attr->mode;
> +}
> +
> static umode_t
> tsx_is_visible(struct kobject *kobj, struct attribute *attr, int i)
> {
> @@ -5370,6 +5383,7 @@ default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
>
> static struct attribute_group group_events_td = {
> .name = "events",
> + .is_visible = td_is_visible,
> };
>
> static struct attribute_group group_events_mem = {
> @@ -5522,6 +5536,23 @@ static inline int hybrid_find_supported_cpu(struct x86_hybrid_pmu *pmu)
> return (cpu >= nr_cpu_ids) ? -1 : cpu;
> }
>
> +static umode_t hybrid_td_is_visible(struct kobject *kobj,
> + struct attribute *attr, int i)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> + struct x86_hybrid_pmu *pmu =
> + container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
> +
> + if (!is_attr_for_this_pmu(kobj, attr))
> + return 0;
> +
> + /* Only check the big core which supports perf metrics */
> + if (pmu->cpu_type == hybrid_big)
> + return (pmu->intel_ctrl & INTEL_PMC_MSK_FIXED_SLOTS) ? attr->mode : 0;
> +
> + return attr->mode;
> +}
> +
> static umode_t hybrid_tsx_is_visible(struct kobject *kobj,
> struct attribute *attr, int i)
> {
> @@ -5548,7 +5579,7 @@ static umode_t hybrid_format_is_visible(struct kobject *kobj,
>
> static struct attribute_group hybrid_group_events_td = {
> .name = "events",
> - .is_visible = hybrid_events_is_visible,
> + .is_visible = hybrid_td_is_visible,
> };
>
> static struct attribute_group hybrid_group_events_mem = {
next prev parent reply other threads:[~2022-10-10 5:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 20:15 kan.liang
2022-10-10 5:03 ` Dongli Zhang [this message]
2022-10-27 16:17 ` Dongli Zhang
2023-12-19 13:22 ` Dongli Zhang
2023-12-19 15:04 ` Liang, Kan
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=91d8d712-f20b-0809-7272-9b16bf83968d@oracle.com \
--to=dongli.zhang@oracle.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=joe.jin@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=likexu@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®