Skip to content

Commit

Permalink
perf/arm-dmc620: Fix lockdep assert in ->event_init()
Browse files Browse the repository at this point in the history
for_each_sibling_event() checks leader's ctx but it doesn't have the ctx
yet if it's the leader.  Like in perf_event_validate_size(), we should
skip checking siblings in that case.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Fixes: f3c0eba ("perf: Add a few assertions")
Reported-by: Greg Thelen <gthelen@google.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Tuan Phan <tuanphan@os.amperecomputing.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20240514180050.182454-1-namhyung@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
namhyung authored and willdeacon committed May 17, 2024
1 parent b8995a1 commit a4c5a45
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/perf/arm_dmc620_pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,16 @@ static int dmc620_pmu_event_init(struct perf_event *event)
if (event->cpu < 0)
return -EINVAL;

hwc->idx = -1;

if (event->group_leader == event)
return 0;

/*
* We can't atomically disable all HW counters so only one event allowed,
* although software events are acceptable.
*/
if (event->group_leader != event &&
!is_software_event(event->group_leader))
if (!is_software_event(event->group_leader))
return -EINVAL;

for_each_sibling_event(sibling, event->group_leader) {
Expand All @@ -556,7 +560,6 @@ static int dmc620_pmu_event_init(struct perf_event *event)
return -EINVAL;
}

hwc->idx = -1;
return 0;
}

Expand Down

0 comments on commit a4c5a45

Please sign in to comment.