Skip to content

Commit 7be51cc

Browse files
author
Peter Zijlstra
committed
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: f3c0eba ("perf: Add a few assertions") Reported-by: Mark Rutland <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/YvvJq2f/7eFVcnNy@FVFF77S0Q05N
1 parent 0ce3804 commit 7be51cc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/events/core.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -2226,16 +2226,22 @@ static inline int __pmu_filter_match(struct perf_event *event)
22262226
static inline int pmu_filter_match(struct perf_event *event)
22272227
{
22282228
struct perf_event *sibling;
2229+
unsigned long flags;
2230+
int ret = 1;
22292231

22302232
if (!__pmu_filter_match(event))
22312233
return 0;
22322234

2235+
local_irq_save(flags);
22332236
for_each_sibling_event(sibling, event) {
2234-
if (!__pmu_filter_match(sibling))
2235-
return 0;
2237+
if (!__pmu_filter_match(sibling)) {
2238+
ret = 0;
2239+
break;
2240+
}
22362241
}
2242+
local_irq_restore(flags);
22372243

2238-
return 1;
2244+
return ret;
22392245
}
22402246

22412247
static inline int

0 commit comments

Comments
 (0)