Skip to contentSkip to conversation

perf/arm-smmuv3: Fix lockdep assert in ->event_init()

PATCH Superseded Chun-Tse Shao 2 participants 3 messages Nov 7, 2024 – Nov 8, 2024 Arm PMU profiling and debugging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 f3c0eba28704 ("perf: Add a few assertions")
Cc Namhyung Kim <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Tuan Phan <[email protected]>
---
 drivers/perf/arm_smmuv3_pmu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +5 -2
index d5fa92ba8373..09789599fccc 100644
@@ -431,6 +431,11 @@ static int smmu_pmu_event_init(struct perf_event *event)
 			return -EINVAL;
 	}
 
+	hwc->idx = -1;
+
+	if (event->group_leader == event)
+		return 0;
+
 	for_each_sibling_event(sibling, event->group_leader) {
 		if (is_software_event(sibling))
 			continue;
@@ -442,8 +447,6 @@ static int smmu_pmu_event_init(struct perf_event *event)
 			return -EINVAL;
 	}
 
-	hwc->idx = -1;
-
 	/*
 	 * Ensure all events are on the same cpu so all events are in the
 	 * same cpu context, to avoid races on pmu_enable etc.
Signature · 1 line
2.47.0.277.g8800431eea-goog
#1 lore raw
Quoted 20 lines · Chun-Tse Shao

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 f3c0eba28704 ("perf: Add a few assertions")
Cc Namhyung Kim <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Tuan Phan <[email protected]>
---
 drivers/perf/arm_smmuv3_pmu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +0 -0
index d5fa92ba8373..09789599fccc 100644

drivers/perf/arm_smmuv3_pmu.c static int smmu_pmu_event_init(struct perf_event *event) · line 434

Quoted 4 lines
drivers/perf/arm_smmuv3_pmu.c +1 -0
@@ -431,6 +431,11 @@ static int smmu_pmu_event_init(struct perf_event *event)
 			return -EINVAL;
 	}
 
+	hwc->idx = -1;

I think you should update the event->cpu as well.

Thanks,
Namhyung

Quoted 19 lines
drivers/perf/arm_smmuv3_pmu.c +4 -2
+
+	if (event->group_leader == event)
+		return 0;
+
 	for_each_sibling_event(sibling, event->group_leader) {
 		if (is_software_event(sibling))
 			continue;
@@ -442,8 +447,6 @@ static int smmu_pmu_event_init(struct perf_event *event)
 			return -EINVAL;
 	}
 
-	hwc->idx = -1;
-
 	/*
 	 * Ensure all events are on the same cpu so all events are in the
 	 * same cpu context, to avoid races on pmu_enable etc.
Signature · 1 line
2.47.0.277.g8800431eea-goog
#2 lore raw

Thank you for your feedback, Namhyung! Please see my v2 patch:
https://lore.kernel.org/all/[email protected]/

Quoted 51 lines · Namhyung Kim
Quoted 20 lines · Chun-Tse Shao

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 f3c0eba28704 ("perf: Add a few assertions")
Cc Namhyung Kim <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Tuan Phan <[email protected]>
---
 drivers/perf/arm_smmuv3_pmu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +0 -0
index d5fa92ba8373..09789599fccc 100644

drivers/perf/arm_smmuv3_pmu.c static int smmu_pmu_event_init(struct perf_event *event) · line 434

Quoted 4 lines
drivers/perf/arm_smmuv3_pmu.c +1 -0
@@ -431,6 +431,11 @@ static int smmu_pmu_event_init(struct perf_event *event)
                      return -EINVAL;
      }
 
+     hwc->idx = -1;

I think you should update the event->cpu as well.

Thanks,
Namhyung

Quoted 19 lines
drivers/perf/arm_smmuv3_pmu.c +4 -3
+
+     if (event->group_leader == event)
+             return 0;
+
      for_each_sibling_event(sibling, event->group_leader) {
              if (is_software_event(sibling))
                      continue;
@@ -442,8 +447,6 @@ static int smmu_pmu_event_init(struct perf_event *event)
                      return -EINVAL;
      }
 
-     hwc->idx = -1;
-
      /*
       * Ensure all events are on the same cpu so all events are in the
       * same cpu context, to avoid races on pmu_enable etc.
--

2.47.0.277.g8800431eea-goog