diff options
author | Ravi Bangoria <ravi.bangoria@amd.com> | 2022-11-22 09:03:26 +0100 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-11-24 11:09:19 +0100 |
commit | bf480f9385667309a8866e65833f261d4773df9a (patch) | |
tree | 7cc9ae1b5ad5eeb38f424b0ad8c3121eeb0feba9 /kernel/events | |
parent | perf/amd/ibs: Make IBS a core pmu (diff) | |
download | linux-bf480f9385667309a8866e65833f261d4773df9a.tar.xz linux-bf480f9385667309a8866e65833f261d4773df9a.zip |
perf/core: Don't allow grouping events from different hw pmus
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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20221122080326.228-1-ravi.bangoria@amd.com
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index f2b865c0e182..65e20c5c3c44 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12503,15 +12503,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; } } |