public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
@ 2024-03-12  1:20 Pu Lehui
  2024-03-12 12:52 ` Conor Dooley
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pu Lehui @ 2024-03-12  1:20 UTC (permalink / raw)
  To: linux-riscv, bpf
  Cc: Atish Patra, Conor Dooley, Anup Patel, Palmer Dabbelt,
	Björn Töpel, Pu Lehui, Pu Lehui

From: Pu Lehui <pulehui@huawei.com>

RISC-V perf driver does not yet support branch sampling. Although the
specification is in the works [0], it is best to disable such events
until support is available, otherwise we will get unexpected results.
Due to this reason, two riscv bpf testcases get_branch_snapshot and
perf_branches/perf_branches_hw fail.

Link: https://github.com/riscv/riscv-control-transfer-records [0]
Fixes: f5bfa23f576f ("RISC-V: Add a perf core library for pmu drivers")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
---
 drivers/perf/riscv_pmu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c
index c78a6fd6c57f..b4efdddb2ad9 100644
--- a/drivers/perf/riscv_pmu.c
+++ b/drivers/perf/riscv_pmu.c
@@ -313,6 +313,10 @@ static int riscv_pmu_event_init(struct perf_event *event)
 	u64 event_config = 0;
 	uint64_t cmask;
 
+	/* driver does not support branch stack sampling */
+	if (has_branch_stack(event))
+		return -EOPNOTSUPP;
+
 	hwc->flags = 0;
 	mapped_event = rvpmu->event_map(event, &event_config);
 	if (mapped_event < 0) {
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
  2024-03-12  1:20 [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported Pu Lehui
@ 2024-03-12 12:52 ` Conor Dooley
  2024-03-12 19:12 ` Atish Patra
  2024-03-27 14:00 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Conor Dooley @ 2024-03-12 12:52 UTC (permalink / raw)
  To: Pu Lehui
  Cc: linux-riscv, bpf, Atish Patra, Anup Patel, Palmer Dabbelt,
	Björn Töpel, Pu Lehui


[-- Attachment #1.1: Type: text/plain, Size: 704 bytes --]

On Tue, Mar 12, 2024 at 01:20:53AM +0000, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> RISC-V perf driver does not yet support branch sampling. Although the
> specification is in the works [0], it is best to disable such events
> until support is available, otherwise we will get unexpected results.
> Due to this reason, two riscv bpf testcases get_branch_snapshot and
> perf_branches/perf_branches_hw fail.
> 
> Link: https://github.com/riscv/riscv-control-transfer-records [0]
> Fixes: f5bfa23f576f ("RISC-V: Add a perf core library for pmu drivers")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
  2024-03-12  1:20 [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported Pu Lehui
  2024-03-12 12:52 ` Conor Dooley
@ 2024-03-12 19:12 ` Atish Patra
  2024-03-27 14:00 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Atish Patra @ 2024-03-12 19:12 UTC (permalink / raw)
  To: Pu Lehui
  Cc: linux-riscv, bpf, Conor Dooley, Anup Patel, Palmer Dabbelt,
	Björn Töpel, Pu Lehui

On Mon, Mar 11, 2024 at 6:19 PM Pu Lehui <pulehui@huaweicloud.com> wrote:
>
> From: Pu Lehui <pulehui@huawei.com>
>
> RISC-V perf driver does not yet support branch sampling. Although the
> specification is in the works [0], it is best to disable such events
> until support is available, otherwise we will get unexpected results.
> Due to this reason, two riscv bpf testcases get_branch_snapshot and
> perf_branches/perf_branches_hw fail.
>
> Link: https://github.com/riscv/riscv-control-transfer-records [0]
> Fixes: f5bfa23f576f ("RISC-V: Add a perf core library for pmu drivers")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>
> ---
>  drivers/perf/riscv_pmu.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c
> index c78a6fd6c57f..b4efdddb2ad9 100644
> --- a/drivers/perf/riscv_pmu.c
> +++ b/drivers/perf/riscv_pmu.c
> @@ -313,6 +313,10 @@ static int riscv_pmu_event_init(struct perf_event *event)
>         u64 event_config = 0;
>         uint64_t cmask;
>
> +       /* driver does not support branch stack sampling */
> +       if (has_branch_stack(event))
> +               return -EOPNOTSUPP;
> +
>         hwc->flags = 0;
>         mapped_event = rvpmu->event_map(event, &event_config);
>         if (mapped_event < 0) {
> --
> 2.34.1
>


Reviewed-by: Atish Patra <atishp@rivosinc.com>
-- 
Regards,
Atish

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
  2024-03-12  1:20 [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported Pu Lehui
  2024-03-12 12:52 ` Conor Dooley
  2024-03-12 19:12 ` Atish Patra
@ 2024-03-27 14:00 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-03-27 14:00 UTC (permalink / raw)
  To: Pu Lehui; +Cc: linux-riscv, bpf, atishp, conor, anup, palmer, bjorn, pulehui

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Tue, 12 Mar 2024 01:20:53 +0000 you wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> RISC-V perf driver does not yet support branch sampling. Although the
> specification is in the works [0], it is best to disable such events
> until support is available, otherwise we will get unexpected results.
> Due to this reason, two riscv bpf testcases get_branch_snapshot and
> perf_branches/perf_branches_hw fail.
> 
> [...]

Here is the summary with links:
  - [v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
    https://git.kernel.org/riscv/c/ea6873118493

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2024-03-27 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12  1:20 [PATCH v2] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported Pu Lehui
2024-03-12 12:52 ` Conor Dooley
2024-03-12 19:12 ` Atish Patra
2024-03-27 14:00 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox