perf: Fix pmu_filter_match()

Mark reported that the new for_each_sibling_event() assertion triggers
in pmu_filter_match() -- which isn't always called with IRQs disabled
or ctx->mutex held.

Fixes: f3c0eba287 ("perf: Add a few assertions")
Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/YvvJq2f/7eFVcnNy@FVFF77S0Q05N
This commit is contained in:
Peter Zijlstra 2022-10-04 11:03:47 +02:00
parent 0ce38047e8
commit 7be51cc1c6
1 changed files with 9 additions and 3 deletions

View File

@ -2226,16 +2226,22 @@ static inline int __pmu_filter_match(struct perf_event *event)
static inline int pmu_filter_match(struct perf_event *event)
{
struct perf_event *sibling;
unsigned long flags;
int ret = 1;
if (!__pmu_filter_match(event))
return 0;
local_irq_save(flags);
for_each_sibling_event(sibling, event) {
if (!__pmu_filter_match(sibling))
return 0;
if (!__pmu_filter_match(sibling)) {
ret = 0;
break;
}
}
local_irq_restore(flags);
return 1;
return ret;
}
static inline int