* [PATCH] perf/core: Don't allow grouping events from different hw pmus
@ 2022-11-22 8:03 Ravi Bangoria
0 siblings, 0 replies; only message in thread
From: Ravi Bangoria @ 2022-11-22 8:03 UTC (permalink / raw)
To: peterz
Cc: ravi.bangoria, mingo, acme, mark.rutland, jolsa, namhyung, bp,
linux-perf-users, linux-kernel, sandipan.das, ananth.narayan,
santosh.shukla
Event group from different hw pmus does not make sense and thus perf
has never allowed it. However, with recent rewrite that restriction
has been inadvertently removed. Fix it.
Fixes: bd2756811766 ("perf: Rewrite core context handling")
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
kernel/events/core.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5f262f91cd31..4ee866ef075d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -12499,15 +12499,21 @@ SYSCALL_DEFINE5(perf_event_open,
* perf_event_pmu_context.
*/
pmu = group_leader->pmu_ctx->pmu;
- } else if (!is_software_event(event) &&
- is_software_event(group_leader) &&
- (group_leader->group_caps & PERF_EV_CAP_SOFTWARE)) {
- /*
- * In case the group is a pure software group, and we
- * try to add a hardware event, move the whole group to
- * the hardware context.
- */
- move_group = 1;
+ } else if (!is_software_event(event)) {
+ if (is_software_event(group_leader) &&
+ (group_leader->group_caps & PERF_EV_CAP_SOFTWARE)) {
+ /*
+ * In case the group is a pure software group, and we
+ * try to add a hardware event, move the whole group to
+ * the hardware context.
+ */
+ move_group = 1;
+ }
+
+ /* Don't allow group of multiple hw events from different pmus */
+ if (!in_software_context(group_leader) &&
+ group_leader->pmu_ctx->pmu != pmu)
+ goto err_locked;
}
}
--
2.38.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-22 8:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 8:03 [PATCH] perf/core: Don't allow grouping events from different hw pmus Ravi Bangoria
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).