From: Andrew Jones <ajones@ventanamicro.com>
To: Yunhui Cui <cuiyunhui@bytedance.com>
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, conor@kernel.org, charlie@rivosinc.com,
samuel.holland@sifive.com, cleger@rivosinc.com,
andybnac@gmail.com, alexghiti@rivosinc.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] RISC-V: Enable cbo.clean/flush in usermode
Date: Tue, 24 Dec 2024 15:11:00 +0100 [thread overview]
Message-ID: <20241224-2148923339996d2eed033b7e@orel> (raw)
In-Reply-To: <20241224123946.97486-1-cuiyunhui@bytedance.com>
On Tue, Dec 24, 2024 at 08:39:46PM +0800, Yunhui Cui wrote:
> Enabling cbo.clean and cbo.flush in user mode makes it more
> convenient to manage the cache state and achieve better performance.
>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> ---
> arch/riscv/kernel/cpufeature.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> index c0916ed318c2..60d180b98f52 100644
> --- a/arch/riscv/kernel/cpufeature.c
> +++ b/arch/riscv/kernel/cpufeature.c
> @@ -30,6 +30,7 @@
> #define NUM_ALPHA_EXTS ('z' - 'a' + 1)
>
> static bool any_cpu_has_zicboz;
> +static bool any_cpu_has_zicbom;
>
> unsigned long elf_hwcap __read_mostly;
>
> @@ -87,6 +88,8 @@ static int riscv_ext_zicbom_validate(const struct riscv_isa_ext_data *data,
> pr_err("Zicbom disabled as cbom-block-size present, but is not a power-of-2\n");
> return -EINVAL;
> }
> +
> + any_cpu_has_zicbom = true;
> return 0;
> }
>
> @@ -944,6 +947,11 @@ void __init riscv_user_isa_enable(void)
> current->thread.envcfg |= ENVCFG_CBZE;
> else if (any_cpu_has_zicboz)
> pr_warn("Zicboz disabled as it is unavailable on some harts\n");
> +
> + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOM))
> + current->thread.envcfg |= ENVCFG_CBCFE;
> + else if (any_cpu_has_zicbom)
> + pr_warn("Zicbom disabled as it is unavailable on some harts\n");
> }
>
> #ifdef CONFIG_RISCV_ALTERNATIVE
> --
> 2.39.2
>
This looks good, so
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
but, as a separate patch, we should also provide hwprobe support like
zicboz has, i.e. add ZICBOM to the IMA ext0 key and add a key for the
zicbom block size. And then, as another patch, add a test_zicbom()
function to tools/testing/selftests/riscv/hwprobe/cbo.c.
Thanks,
drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-12-24 14:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 12:39 [PATCH v2] RISC-V: Enable cbo.clean/flush in usermode Yunhui Cui
2024-12-24 14:11 ` Andrew Jones [this message]
2024-12-25 2:38 ` [External] " yunhui cui
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=20241224-2148923339996d2eed033b7e@orel \
--to=ajones@ventanamicro.com \
--cc=alexghiti@rivosinc.com \
--cc=andybnac@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=conor@kernel.org \
--cc=cuiyunhui@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=samuel.holland@sifive.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