* [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
@ 2025-07-21 16:07 Manuel Hernández Méndez
2025-08-26 11:15 ` Anup Patel
0 siblings, 1 reply; 2+ messages in thread
From: Manuel Hernández Méndez @ 2025-07-21 16:07 UTC (permalink / raw)
To: opensbi; +Cc: 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 <maherme.dev@gmail.com>
---
lib/sbi/sbi_pmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index 07a5c544..635cb0c7 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -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
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw
2025-07-21 16:07 [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw Manuel Hernández Méndez
@ 2025-08-26 11:15 ` Anup Patel
0 siblings, 0 replies; 2+ messages in thread
From: Anup Patel @ 2025-08-26 11:15 UTC (permalink / raw)
To: Manuel Hernández Méndez; +Cc: opensbi
On Mon, Jul 21, 2025 at 10:31 PM Manuel Hernández Méndez
<maherme.dev@gmail.com> wrote:
>
> 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 <maherme.dev@gmail.com>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> lib/sbi/sbi_pmu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
> index 07a5c544..635cb0c7 100644
> --- a/lib/sbi/sbi_pmu.c
> +++ b/lib/sbi/sbi_pmu.c
> @@ -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
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-26 11:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 16:07 [PATCH] lib: sbi: pmu: Improve loop in pmu_ctr_find_hw Manuel Hernández Méndez
2025-08-26 11:15 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox