lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
PATCH 1/1 lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
We do not need to iterate over all values in the loop, we can break the loop when we found a valid counter that is not started yet.
Signed-off-by Manuel Hernández Méndez <[email protected]>
--- lib/sbi/sbi_pmu.c | 1 + 1 file changed, 1 insertion(+)
lib/sbi/sbi_pmu.c +1 -0
@@ -780,6 +780,7 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,continue ;/* We found a valid counter that is not started yet */ ctr_idx = cbase; +break ; } }
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedQuoted 6 lines · Manuel Hernández Méndez
We do not need to iterate over all values in the loop, we can break the loop when we found a valid counter that is not started yet.
Signed-off-by Manuel Hernández Méndez <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 24 lines
--- lib/sbi/sbi_pmu.c | 1 + 1 file changed, 1 insertion(+)lib/sbi/sbi_pmu.c +1
-1@@ -780,6 +780,7 @@ static int pmu_ctr_find_hw(struct sbi_pmu_hart_state *phs,continue ;/* We found a valid counter that is not started yet */ ctr_idx = cbase; +break ; } } --2.34.1
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi