Skip to content

Commit f818947

Browse files
tititiou36willdeacon
authored andcommitted
perf/arm-cci: Slightly optimize cci_pmu_sync_counters()
When the 'mask' bitmap is cleared, it is better to use its full maximum size instead of only the needed size. This lets the compiler optimize it because the size is now known at compile time. HW_CNTRS_MAX is small (i.e. currently 9), so a call to memset() is saved. Also, as 'mask' is local to the function, the non-atomic __set_bit() can also safely be used here. Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/88d4e20d595f771396e9d558c1587eb4494057db.1682022422.git.christophe.jaillet@wanadoo.fr Signed-off-by: Will Deacon <[email protected]>
1 parent 44c026a commit f818947

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/perf/arm-cci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static void cci_pmu_sync_counters(struct cci_pmu *cci_pmu)
645645
struct cci_pmu_hw_events *cci_hw = &cci_pmu->hw_events;
646646
DECLARE_BITMAP(mask, HW_CNTRS_MAX);
647647

648-
bitmap_zero(mask, cci_pmu->num_cntrs);
648+
bitmap_zero(mask, HW_CNTRS_MAX);
649649
for_each_set_bit(i, cci_pmu->hw_events.used_mask, cci_pmu->num_cntrs) {
650650
struct perf_event *event = cci_hw->events[i];
651651

@@ -656,7 +656,7 @@ static void cci_pmu_sync_counters(struct cci_pmu *cci_pmu)
656656
if (event->hw.state & PERF_HES_STOPPED)
657657
continue;
658658
if (event->hw.state & PERF_HES_ARCH) {
659-
set_bit(i, mask);
659+
__set_bit(i, mask);
660660
event->hw.state &= ~PERF_HES_ARCH;
661661
}
662662
}

0 commit comments

Comments
 (0)