[PATCH] drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported

Conor Dooley conor at kernel.org
Thu Mar 7 09:52:45 PST 2024


On Tue, Mar 05, 2024 at 03:52:23PM +0000, Pu Lehui wrote:
> From: Pu Lehui <pulehui at huawei.com>
> 
> RISC-V perf does not yet support branch sampling. Two riscv bpf
> testcases get_branch_snapshot and perf_branches/perf_branches_hw failed
> due to not disabling such sampling.
> 
> Signed-off-by: Pu Lehui <pulehui at huawei.com>

This seems worthy of a fixes tag. For what commit I do not know, but I
figure it is a problem currently in mainline and a fix should be
backported?

> ---
>  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..bc42cb95a97c 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;
>  
> +	/* does not support taken branch sampling */

Skimming patchwork, I found this comment confusing.
Isolated from the commit message, which it will be once committed, it
was not immediately clear that you were referring to the driver. I think
it is just matter of making this a complete sentence that starts by
mentioning /what/ does not support this feature. Is it the driver? Does
the spec not allow it? etc

Cheers,
Conor.

> +	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
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20240307/6cf87ab0/attachment.sig>


More information about the linux-riscv mailing list