Skip to content

Commit 02a55f2

Browse files
Chun-Tse Shaoctmarinas
authored andcommitted
perf/arm-smmuv3: Fix lockdep assert in ->event_init()
Same as https://lore.kernel.org/all/[email protected]/, we should skip `for_each_sibling_event()` for group leader since it doesn't have the ctx yet. Fixes: f3c0eba ("perf: Add a few assertions") Reported-by: Greg Thelen <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Tuan Phan <[email protected]> Signed-off-by: Chun-Tse Shao <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent a63d740 commit 02a55f2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/perf/arm_smmuv3_pmu.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@ static int smmu_pmu_event_init(struct perf_event *event)
431431
return -EINVAL;
432432
}
433433

434+
/*
435+
* Ensure all events are on the same cpu so all events are in the
436+
* same cpu context, to avoid races on pmu_enable etc.
437+
*/
438+
event->cpu = smmu_pmu->on_cpu;
439+
440+
hwc->idx = -1;
441+
442+
if (event->group_leader == event)
443+
return 0;
444+
434445
for_each_sibling_event(sibling, event->group_leader) {
435446
if (is_software_event(sibling))
436447
continue;
@@ -442,14 +453,6 @@ static int smmu_pmu_event_init(struct perf_event *event)
442453
return -EINVAL;
443454
}
444455

445-
hwc->idx = -1;
446-
447-
/*
448-
* Ensure all events are on the same cpu so all events are in the
449-
* same cpu context, to avoid races on pmu_enable etc.
450-
*/
451-
event->cpu = smmu_pmu->on_cpu;
452-
453456
return 0;
454457
}
455458

0 commit comments

Comments
 (0)