* [PATCH 6.6] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
@ 2024-11-29 6:08 Hagar Hemdan
2024-11-29 6:08 ` [PATCH 6.1] " Hagar Hemdan
2024-11-29 20:03 ` [PATCH 6.6] " Sasha Levin
0 siblings, 2 replies; 4+ messages in thread
From: Hagar Hemdan @ 2024-11-29 6:08 UTC (permalink / raw)
Cc: stable, Kan Liang, Dongli Zhang, Peter Zijlstra, Hagar Hemdan
From: Kan Liang <kan.liang@linux.intel.com>
[ Upstream commit 556a7c039a52c21da33eaae9269984a1ef59189b ]
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
perf-metrics feature is not enumerated.
The big core of a hybrid platform can also supports the perf-metrics
feature. Fix the hybrid platform as well.
Closes: https://lore.kernel.org/lkml/CAM9d7cj8z+ryyzUHR+P1Dcpot2jjW+Qcc4CPQpfafTXN=LEU0Q@mail.gmail.com/
Reported-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lkml.kernel.org/r/20240708193336.1192217-2-kan.liang@linux.intel.com
[ Minor changes to make it work on 6.6 ]
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
---
arch/x86/events/intel/core.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 27968d10dd0b..3bc31cd20c81 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -5409,8 +5409,22 @@ default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
return attr->mode;
}
+static umode_t
+td_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+{
+ /*
+ * Hide the perf metrics topdown events
+ * if the feature is not enumerated.
+ */
+ if (x86_pmu.num_topdown_events)
+ return x86_pmu.intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
+}
+
static struct attribute_group group_events_td = {
.name = "events",
+ .is_visible = td_is_visible,
};
static struct attribute_group group_events_mem = {
@@ -5587,9 +5601,27 @@ static umode_t hybrid_format_is_visible(struct kobject *kobj,
return (cpu >= 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode : 0;
}
+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 the big core supports perf metrics */
+ if (pmu->cpu_type == hybrid_big)
+ return pmu->intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
+}
+
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 = {
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.1] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
2024-11-29 6:08 [PATCH 6.6] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated Hagar Hemdan
@ 2024-11-29 6:08 ` Hagar Hemdan
2024-11-29 20:03 ` Sasha Levin
2024-11-29 20:03 ` [PATCH 6.6] " Sasha Levin
1 sibling, 1 reply; 4+ messages in thread
From: Hagar Hemdan @ 2024-11-29 6:08 UTC (permalink / raw)
Cc: stable, Kan Liang, Dongli Zhang, Peter Zijlstra, Hagar Hemdan
From: Kan Liang <kan.liang@linux.intel.com>
[ Upstream commit 556a7c039a52c21da33eaae9269984a1ef59189b ]
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
perf-metrics feature is not enumerated.
The big core of a hybrid platform can also supports the perf-metrics
feature. Fix the hybrid platform as well.
Closes: https://lore.kernel.org/lkml/CAM9d7cj8z+ryyzUHR+P1Dcpot2jjW+Qcc4CPQpfafTXN=LEU0Q@mail.gmail.com/
Reported-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lkml.kernel.org/r/20240708193336.1192217-2-kan.liang@linux.intel.com
[ Minor changes to make it work on 6.1 ]
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
---
arch/x86/events/intel/core.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 27968d10dd0b..3bc31cd20c81 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -5409,8 +5409,22 @@ default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
return attr->mode;
}
+static umode_t
+td_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+{
+ /*
+ * Hide the perf metrics topdown events
+ * if the feature is not enumerated.
+ */
+ if (x86_pmu.num_topdown_events)
+ return x86_pmu.intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
+}
+
static struct attribute_group group_events_td = {
.name = "events",
+ .is_visible = td_is_visible,
};
static struct attribute_group group_events_mem = {
@@ -5587,9 +5601,27 @@ static umode_t hybrid_format_is_visible(struct kobject *kobj,
return (cpu >= 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode : 0;
}
+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 the big core supports perf metrics */
+ if (pmu->cpu_type == hybrid_big)
+ return pmu->intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
+}
+
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 = {
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 6.6] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
2024-11-29 6:08 [PATCH 6.6] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated Hagar Hemdan
2024-11-29 6:08 ` [PATCH 6.1] " Hagar Hemdan
@ 2024-11-29 20:03 ` Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2024-11-29 20:03 UTC (permalink / raw)
To: stable; +Cc: Hagar Hemdan, Sasha Levin
[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: 556a7c039a52c21da33eaae9269984a1ef59189b
WARNING: Author mismatch between patch and upstream commit:
Backport author: Hagar Hemdan <hagarhem@amazon.com>
Commit author: Kan Liang <kan.liang@linux.intel.com>
Status in newer kernel trees:
6.12.y | Present (exact SHA1)
6.11.y | Present (exact SHA1)
6.6.y | Not found
Note: The patch differs from the upstream commit:
---
1: 556a7c039a52c ! 1: 46084b673b37e perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
@@ Metadata
## Commit message ##
perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
+ [ Upstream commit 556a7c039a52c21da33eaae9269984a1ef59189b ]
+
The below error is observed on Ice Lake VM.
$ perf stat
@@ Commit message
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lkml.kernel.org/r/20240708193336.1192217-2-kan.liang@linux.intel.com
+ [ Minor changes to make it work on 6.6 ]
+ Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
## arch/x86/events/intel/core.c ##
-@@ arch/x86/events/intel/core.c: exra_is_visible(struct kobject *kobj, struct attribute *attr, int i)
- return x86_pmu.version >= 2 ? attr->mode : 0;
+@@ arch/x86/events/intel/core.c: default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+ return attr->mode;
}
+static umode_t
@@ arch/x86/events/intel/core.c: exra_is_visible(struct kobject *kobj, struct attri
static struct attribute_group group_events_mem = {
@@ arch/x86/events/intel/core.c: static umode_t hybrid_format_is_visible(struct kobject *kobj,
- return (cpu >= 0) && (pmu->pmu_type & pmu_attr->pmu_type) ? attr->mode : 0;
+ return (cpu >= 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode : 0;
}
+static umode_t hybrid_td_is_visible(struct kobject *kobj,
@@ arch/x86/events/intel/core.c: static umode_t hybrid_format_is_visible(struct kob
+
+
+ /* Only the big core supports perf metrics */
-+ if (pmu->pmu_type == hybrid_big)
++ if (pmu->cpu_type == hybrid_big)
+ return pmu->intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y | Success | Success |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6.1] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
2024-11-29 6:08 ` [PATCH 6.1] " Hagar Hemdan
@ 2024-11-29 20:03 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2024-11-29 20:03 UTC (permalink / raw)
To: stable; +Cc: Hagar Hemdan, Sasha Levin
[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: 556a7c039a52c21da33eaae9269984a1ef59189b
WARNING: Author mismatch between patch and upstream commit:
Backport author: Hagar Hemdan <hagarhem@amazon.com>
Commit author: Kan Liang <kan.liang@linux.intel.com>
Status in newer kernel trees:
6.12.y | Present (exact SHA1)
6.11.y | Present (exact SHA1)
6.6.y | Not found
6.1.y | Not found
Note: The patch differs from the upstream commit:
---
1: 556a7c039a52c ! 1: 39f65e280d338 perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
@@ Metadata
## Commit message ##
perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
+ [ Upstream commit 556a7c039a52c21da33eaae9269984a1ef59189b ]
+
The below error is observed on Ice Lake VM.
$ perf stat
@@ Commit message
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lkml.kernel.org/r/20240708193336.1192217-2-kan.liang@linux.intel.com
+ [ Minor changes to make it work on 6.1 ]
+ Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
## arch/x86/events/intel/core.c ##
-@@ arch/x86/events/intel/core.c: exra_is_visible(struct kobject *kobj, struct attribute *attr, int i)
- return x86_pmu.version >= 2 ? attr->mode : 0;
+@@ arch/x86/events/intel/core.c: default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+ return attr->mode;
}
+static umode_t
@@ arch/x86/events/intel/core.c: exra_is_visible(struct kobject *kobj, struct attri
static struct attribute_group group_events_mem = {
@@ arch/x86/events/intel/core.c: static umode_t hybrid_format_is_visible(struct kobject *kobj,
- return (cpu >= 0) && (pmu->pmu_type & pmu_attr->pmu_type) ? attr->mode : 0;
+ return (cpu >= 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode : 0;
}
+static umode_t hybrid_td_is_visible(struct kobject *kobj,
@@ arch/x86/events/intel/core.c: static umode_t hybrid_format_is_visible(struct kob
+
+
+ /* Only the big core supports perf metrics */
-+ if (pmu->pmu_type == hybrid_big)
++ if (pmu->cpu_type == hybrid_big)
+ return pmu->intel_cap.perf_metrics ? attr->mode : 0;
+
+ return attr->mode;
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y | Success | Success |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-29 20:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 6:08 [PATCH 6.6] perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated Hagar Hemdan
2024-11-29 6:08 ` [PATCH 6.1] " Hagar Hemdan
2024-11-29 20:03 ` Sasha Levin
2024-11-29 20:03 ` [PATCH 6.6] " Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox