From: Yao Zi <ziyao@disroot.org>
To: Yunhui Cui <cuiyunhui@bytedance.com>,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, alex@ghiti.fr, rostedt@goodmis.org,
mhiramat@kernel.org, mark.rutland@arm.com, peterz@infradead.org,
jpoimboe@kernel.org, jbaron@akamai.com, ardb@kernel.org,
willy@infradead.org, guoren@kernel.org, ziy@nvidia.com,
akpm@linux-foundation.org, bjorn@rivosinc.com,
ajones@ventanamicro.com, parri.andrea@gmail.com,
cleger@rivosinc.com, yongxuan.wang@sifive.com,
inochiama@gmail.com, samuel.holland@sifive.com,
charlie@rivosinc.com, conor.dooley@microchip.com,
yikming2222@gmail.com, andybnac@gmail.com, yury.norov@gmail.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] riscv: add support for Ziccid
Date: Thu, 9 Oct 2025 16:45:18 +0000 [thread overview]
Message-ID: <aOfmnjJmQAdR1wD4@pie> (raw)
In-Reply-To: <20251009134514.8549-1-cuiyunhui@bytedance.com>
On Thu, Oct 09, 2025 at 09:45:14PM +0800, Yunhui Cui wrote:
> The Ziccid extension provides hardware synchronization between
> Dcache and Icache. With this hardware support, there's no longer
> a need to trigger remote hart execution of fence.i via IPI.
This description looks wrong to me: Ziccid only guarantees code
modification **eventually** becomes visible to remote HARTs, not
immediately. Quoting a paragraph from documentation of Ziccid[1],
> Since, under Ziccid, instruction fetches appear in the global memory
> order, the RVWMO progress axiom suffices to guarantee that stores
> **eventually** become visible to instruction fetches, even without
> executing a FENCE.I instruction.
and an issue[2] in the same repository (Ziccid hardware implementation &
software model),
> > Is fence.i still necessary in any case with the presence of Ziccid
>
> The only thing that Ziccid guarantees is that stores eventually become
> visible to instruction fetch. It doesn't guarantee that stores
> immediately become visible to instruction fetch, even on the same
> hart.
>
> So, fence.i is still usually necessary. The only situations in which
> fence.i is not necessary is when race conditions in code patching are
> functionally acceptable, i.e. when it doesn't matter whether the old
> code or new code is executed.
So it's definitely wrong to state "there's no longer a need to trigger
remote hart execution of fence.i".
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> ---
> arch/riscv/include/asm/cacheflush.h | 4 ++--
> arch/riscv/include/asm/hwcap.h | 1 +
> arch/riscv/include/asm/switch_to.h | 10 ++++++++++
> arch/riscv/kernel/cpufeature.c | 1 +
> arch/riscv/kernel/ftrace.c | 2 +-
> arch/riscv/kernel/hibernate.c | 2 +-
> arch/riscv/kernel/jump_label.c | 2 +-
> arch/riscv/mm/cacheflush.c | 16 ++++++++++++++--
> 8 files changed, 31 insertions(+), 7 deletions(-)
>
...
> -void flush_icache_all(void)
> +void flush_icache_all(bool force)
> {
> local_flush_icache_all();
>
> if (num_online_cpus() < 2)
> return;
>
> + if (!force)
> + asm goto(ALTERNATIVE("nop", "j %l[ziccid]", 0,
> + RISCV_ISA_EXT_ZICCID, 1)
> + : : : : ziccid);
and even in the patch, a remote-fence is still triggered if
flush_icache_all() is called with force set to true.
Best regards,
Yao Zi
[1]: https://github.com/aswaterman/riscv-misc/blob/e4fe3aa7b4d5b/isa/ziccid.adoc?plain=1#L139-L158
[2]: https://github.com/aswaterman/riscv-misc/issues/4#issuecomment-2884984633
> /*
> * Make sure all previous writes to the D$ are ordered before making
> * the IPI. The RISC-V spec states that a hart must execute a data fence
> @@ -41,6 +46,7 @@ void flush_icache_all(void)
> sbi_remote_fence_i(NULL);
> else
> on_each_cpu(ipi_remote_fence_i, NULL, 1);
> +ziccid:;
> }
> EXPORT_SYMBOL(flush_icache_all);
next prev parent reply other threads:[~2025-10-09 16:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 13:45 [PATCH RFC] riscv: add support for Ziccid Yunhui Cui
2025-10-09 16:45 ` Yao Zi [this message]
2025-10-16 9:24 ` [External] " yunhui cui
2025-10-09 16:53 ` Conor Dooley
2025-10-10 17:48 ` Yury Norov
2025-10-12 11:23 ` Guo Ren
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=aOfmnjJmQAdR1wD4@pie \
--to=ziyao@disroot.org \
--cc=ajones@ventanamicro.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=andybnac@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=bjorn@rivosinc.com \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=cuiyunhui@bytedance.com \
--cc=guoren@kernel.org \
--cc=inochiama@gmail.com \
--cc=jbaron@akamai.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=palmer@dabbelt.com \
--cc=parri.andrea@gmail.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=samuel.holland@sifive.com \
--cc=willy@infradead.org \
--cc=yikming2222@gmail.com \
--cc=yongxuan.wang@sifive.com \
--cc=yury.norov@gmail.com \
--cc=ziy@nvidia.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 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).