From: Conor Dooley <conor@kernel.org>
To: Evan Green <evan@rivosinc.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>,
linux-doc@vger.kernel.org, Yangyu Chen <cyy@cyyself.name>,
Conor Dooley <conor.dooley@microchip.com>,
Guo Ren <guoren@kernel.org>, Jisheng Zhang <jszhang@kernel.org>,
linux-riscv@lists.infradead.org, Jonathan Corbet <corbet@lwn.net>,
Xianting Tian <xianting.tian@linux.alibaba.com>,
Marc Zyngier <maz@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Greentime Hu <greentime.hu@sifive.com>,
Simon Hosie <shosie@rivosinc.com>,
Li Zhengyu <lizhengyu3@huawei.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alexghiti@rivosinc.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Heiko Stuebner <heiko.stuebner@vrull.eu>,
Anup Patel <apatel@ventanamicro.com>,
linux-kernel@vger.kernel.org,
David Laight <David.Laight@aculab.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Andy Chiu <andy.chiu@sifive.com>,
Andrew Jones <ajones@ventanamicro.com>
Subject: Re: [PATCH v2 1/2] RISC-V: Probe for unaligned access speed
Date: Thu, 13 Jul 2023 18:21:35 +0100 [thread overview]
Message-ID: <20230713-unaligned-engaging-af88fa5fd9c8@spud> (raw)
In-Reply-To: <20230705164833.995516-2-evan@rivosinc.com>
[-- Attachment #1: Type: text/plain, Size: 2934 bytes --]
On Wed, Jul 05, 2023 at 09:48:32AM -0700, Evan Green wrote:
I got kinda mad about the whole Zicclsm thing, so I decided to take a
bit before reading the words "aligned access" again.
> diff --git a/Documentation/riscv/hwprobe.rst b/Documentation/riscv/hwprobe.rst
> index 19165ebd82ba..88d7d64ec0bd 100644
> --- a/Documentation/riscv/hwprobe.rst
> +++ b/Documentation/riscv/hwprobe.rst
> @@ -87,13 +87,12 @@ The following keys are defined:
> emulated via software, either in or below the kernel. These accesses are
> always extremely slow.
>
> - * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are supported
> - in hardware, but are slower than the cooresponding aligned accesses
> - sequences.
> + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are slower
> + than equivalent byte accesses. Misaligned accesses may be supported
> + directly in hardware, or trapped and emulated by software.
>
> - * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are supported
> - in hardware and are faster than the cooresponding aligned accesses
> - sequences.
> + * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are faster
> + than equivalent byte accesses.
The indent here for line #2 looks odd. Is that an artifact of the patch?
> diff --git a/arch/riscv/kernel/copy-unaligned.h b/arch/riscv/kernel/copy-unaligned.h
> new file mode 100644
> index 000000000000..a4e8b6ad5b6a
> --- /dev/null
> +++ b/arch/riscv/kernel/copy-unaligned.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2023 Rivos, Inc.
> + */
> +#ifndef __RISCV_KERNEL_COPY_UNALIGNED_H
> +#define __RISCV_KERNEL_COPY_UNALIGNED_H
> +
> +#include <linux/types.h>
> +
> +void __copy_words_unaligned(void *dst, const void *src, size_t size);
> +void __copy_bytes_unaligned(void *dst, const void *src, size_t size);
If we are putting this stuff in headers to call into asm, should we
prefix it with "riscv", or is __ enough?
> +void check_unaligned_access(int cpu)
> +{
> + u64 c0, c1;
I quite dislike variables like "c0"/"c1", they make things harder to
read for no real benefit IMO. Would you mind renaming them?
> + u64 word_cycles;
> + u64 byte_cycles;
> + int ratio;
> + unsigned long j0, j1;
> + struct page *page;
> + void *dst;
> + void *src;
> + long speed = RISCV_HWPROBE_MISALIGNED_SLOW;
> +static int check_unaligned_access0(void)
> +{
> + check_unaligned_access(0);
> + return 0;
> +}
> +arch_initcall(check_unaligned_access0);
Could you please rename this function to match the actual use?
So something like s/0/_boot_cpu/?
Otherwise, I like the idea & we discussed the semantics last time around
and I was happy with them. I don't feel qualified to review the actual
speed test, so
Acked-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2023-07-13 17:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 16:48 [PATCH v2 0/2] RISC-V: Probe for misaligned access speed Evan Green
2023-07-05 16:48 ` [PATCH v2 1/2] RISC-V: Probe for unaligned " Evan Green
2023-07-13 17:21 ` Conor Dooley [this message]
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=20230713-unaligned-engaging-af88fa5fd9c8@spud \
--to=conor@kernel.org \
--cc=David.Laight@aculab.com \
--cc=ajones@ventanamicro.com \
--cc=alexghiti@rivosinc.com \
--cc=andy.chiu@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=conor.dooley@microchip.com \
--cc=corbet@lwn.net \
--cc=cyy@cyyself.name \
--cc=evan@rivosinc.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@kernel.org \
--cc=heiko.stuebner@vrull.eu \
--cc=jszhang@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lizhengyu3@huawei.com \
--cc=masahiroy@kernel.org \
--cc=maz@kernel.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=shosie@rivosinc.com \
--cc=xianting.tian@linux.alibaba.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