linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: riscv: skip empty batches in counter start
@ 2025-08-04  2:51 Yunhui Cui
  2025-08-04  4:54 ` Anup Patel
  0 siblings, 1 reply; 2+ messages in thread
From: Yunhui Cui @ 2025-08-04  2:51 UTC (permalink / raw)
  To: atish.patra, anup, will, mark.rutland, paul.walmsley, palmer, aou,
	alex, linux-riscv, linux-arm-kernel, linux-perf-users,
	linux-kernel
  Cc: Yunhui Cui

Avoid unnecessary SBI calls when starting non-overflowed counters
in pmu_sbi_start_ovf_ctrs_sbi() by checking ctr_start_mask.

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
 drivers/perf/riscv_pmu_sbi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
index 698de8ddf895b..3977f7488e4ef 100644
--- a/drivers/perf/riscv_pmu_sbi.c
+++ b/drivers/perf/riscv_pmu_sbi.c
@@ -877,8 +877,10 @@ static inline void pmu_sbi_start_ovf_ctrs_sbi(struct cpu_hw_events *cpu_hw_evt,
 	for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
 		ctr_start_mask = cpu_hw_evt->used_hw_ctrs[i] & ~ctr_ovf_mask;
 		/* Start all the counters that did not overflow in a single shot */
-		sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, ctr_start_mask,
-			0, 0, 0, 0);
+		if (ctr_start_mask) {
+			sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG,
+				  ctr_start_mask, 0, 0, 0, 0);
+		}
 	}
 
 	/* Reinitialize and start all the counter that overflowed */
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf: riscv: skip empty batches in counter start
  2025-08-04  2:51 [PATCH] perf: riscv: skip empty batches in counter start Yunhui Cui
@ 2025-08-04  4:54 ` Anup Patel
  0 siblings, 0 replies; 2+ messages in thread
From: Anup Patel @ 2025-08-04  4:54 UTC (permalink / raw)
  To: Yunhui Cui
  Cc: atish.patra, will, mark.rutland, paul.walmsley, palmer, aou, alex,
	linux-riscv, linux-arm-kernel, linux-perf-users, linux-kernel

On Mon, Aug 4, 2025 at 8:21 AM Yunhui Cui <cuiyunhui@bytedance.com> wrote:
>
> Avoid unnecessary SBI calls when starting non-overflowed counters
> in pmu_sbi_start_ovf_ctrs_sbi() by checking ctr_start_mask.
>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>

LGTM.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

> ---
>  drivers/perf/riscv_pmu_sbi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index 698de8ddf895b..3977f7488e4ef 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -877,8 +877,10 @@ static inline void pmu_sbi_start_ovf_ctrs_sbi(struct cpu_hw_events *cpu_hw_evt,
>         for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
>                 ctr_start_mask = cpu_hw_evt->used_hw_ctrs[i] & ~ctr_ovf_mask;
>                 /* Start all the counters that did not overflow in a single shot */
> -               sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, ctr_start_mask,
> -                       0, 0, 0, 0);
> +               if (ctr_start_mask) {
> +                       sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG,
> +                                 ctr_start_mask, 0, 0, 0, 0);
> +               }
>         }
>
>         /* Reinitialize and start all the counter that overflowed */
> --
> 2.39.5
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-04  4:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04  2:51 [PATCH] perf: riscv: skip empty batches in counter start Yunhui Cui
2025-08-04  4:54 ` Anup Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).