From: sashiko-bot@kernel.org
To: "Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
linux-perf-users@vger.kernel.org
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH v1 3/5] perf: riscv: Probe the experimental PDIS CSR layout on matching CPUs
Date: Wed, 18 Nov 2026 08:39:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-220464@kernel.org> (raw)
In-Reply-To: <20261118081327.10684-10-zhangzhanpeng.jasper@bytedance.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf: riscv: unguarded non-volatile asm goto output in
pdis_read_csr()
- [Low] perf: riscv: riscv_pdis_cpu_starting() leaves counter CSR dirty
on error
--
commit 5b0b1f9bcdc0e64d6c714a4382c017740354c7f9
Author: Zhanpeng Zhang <zhangzhanpeng.jasper@bytedance.com>
perf: riscv: Probe the experimental PDIS CSR layout on matching CPUs
This commit adds opt-in CPU bringup probing and teardown quiescing for the
experimental RISC-V PDIS CSR layout behind CONFIG_RISCV_PDIS_CSR and the
riscv_pdis_test boot parameter.
> diff --git a/drivers/perf/riscv_pdis.c b/drivers/perf/riscv_pdis.c
> new file mode 100644
> index 0000000000000..b7671e5ad63eb
> --- /dev/null
> +++ b/drivers/perf/riscv_pdis.c
> @@ -0,0 +1,137 @@
[ ... ]
> +/* Used only during opt-in probing; missing/unauthorized CSRs must not oops. */
> +static __always_inline int pdis_read_csr(unsigned int csr, unsigned long *value)
> +{
> + asm goto("1: csrr %[value], %[csr]\n"
> + _ASM_EXTABLE(1b, %l[fault])
> + : [value] "=r" (*value) : [csr] "i" (csr) : "memory" : fault);
> + return 0;
> +fault:
> + *value = 0;
> + return -ENODEV;
> +}
[Severity: Medium]
Does pdis_read_csr() break compilation or risk miscompilation on older GCC
versions by using raw asm goto with an output operand without checking
CONFIG_CC_HAS_ASM_GOTO_OUTPUT?
GCC only added syntax support for asm goto output operands in GCC 11, and
scripts/Kconfig.toolchain disables CONFIG_CC_HAS_ASM_GOTO_OUTPUT on GCC
versions affected by GCC PR 113921 (< 11.5, 12.0..12.3, and 13.0..13.2),
where inlining asm goto with outputs can miscompile the fault label edge.
In addition, asm goto with outputs is not implicitly volatile in GCC
(GCC PR 103979), so callers use asm_goto_output() from
include/linux/compiler_types.h to include the volatile qualifier.
Could RISCV_PDIS_CSR depend on CC_HAS_ASM_GOTO_OUTPUT (or provide a
!CONFIG_CC_HAS_ASM_GOTO_OUTPUT fallback) and use asm_goto_output() here?
[ ... ]
> +void riscv_pdis_cpu_starting(void)
> +{
[ ... ]
> + /* The first version requires all 32 COUNT and INITVAL bits. */
> + if (pdis_write_csr(RISCV_PDIS_CSR_COUNTER, ~0UL) ||
> + pdis_read_csr(RISCV_PDIS_CSR_COUNTER, &value) || value != ~0UL ||
> + pdis_write_csr(RISCV_PDIS_CSR_COUNTER, 0))
> + return;
[Severity: Low]
Does riscv_pdis_cpu_starting() leave RISCV_PDIS_CSR_COUNTER set to non-zero
when value != ~0UL?
If the write and read succeed but the register implements fewer than 64
writable bits, short-circuit evaluation of value != ~0UL skips the
pdis_write_csr(RISCV_PDIS_CSR_COUNTER, 0) call and returns with all
implemented counter and initval bits left set to 1.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118081327.10684-7-zhangzhanpeng.jasper@bytedance.com?part=3
next prev parent reply other threads:[~2026-11-18 8:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 8:13 [RFC PATCH v1 0/5] RISC-V: Add perf support for PDIS Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:13 ` [RFC PATCH v1 1/5] dt-bindings: riscv: Add Smpdis and Sspdis ISA extensions Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:23 ` sashiko-bot
2026-11-18 8:13 ` [RFC PATCH v1 2/5] riscv: Detect " Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:20 ` sashiko-bot
2026-11-18 8:13 ` [RFC PATCH v1 3/5] perf: riscv: Probe the experimental PDIS CSR layout on matching CPUs Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:39 ` sashiko-bot [this message]
2026-11-18 8:13 ` [RFC PATCH v1 4/5] perf: riscv: Add PDIS event and counter callbacks Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:49 ` sashiko-bot
2026-11-18 8:13 ` [RFC PATCH v1 5/5] perf: riscv: Deliver PDIS samples through the SBI PMU interrupt Zhanpeng Zhang
2026-11-18 8:13 ` Zhanpeng Zhang
2026-11-18 8:47 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-220464@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhangzhanpeng.jasper@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.