mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] RISC-V: Probe for misaligned access speed
@ 2023-06-23 22:20 Evan Green
  2023-06-23 22:20 ` [PATCH 1/2] RISC-V: Probe for unaligned " Evan Green
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Evan Green @ 2023-06-23 22:20 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: Simon Hosie, Evan Green, Albert Ou, Alexandre Ghiti,
	Andrew Jones, Andy Chiu, Anup Patel, Conor Dooley, Greentime Hu,
	Guo Ren, Heiko Stuebner, Heiko Stuebner, Jisheng Zhang,
	Jonathan Corbet, Ley Foon Tan, Li Zhengyu, Masahiro Yamada,
	Palmer Dabbelt, Paul Walmsley, Randy Dunlap, Samuel Holland,
	Sia Jee Heng, Sunil V L, Xianting Tian, Yangyu Chen, linux-doc,
	linux-kernel, linux-riscv


The current setting for the hwprobe bit indicating misaligned access
speed is controlled by a vendor-specific feature probe function. This is
essentially a per-SoC table we have to maintain on behalf of each vendor
going forward. Let's convert that instead to something we detect at
runtime.

We have two assembly routines at the heart of our probe: one that
does a bunch of word-sized accesses (without aligning its input buffer),
and the other that does byte accesses. If we can move a larger number of
bytes using misaligned word accesses than we can with the same amount of
time doing byte accesses, then we can declare misaligned accesses as
"fast".

The tradeoff of reducing this maintenance burden is boot time. We spend
4-6 jiffies per core doing this measurement (0-2 on jiffie edge
alignment, and 4 on measurement). The timing loop was based on
raid6_choose_gen(), which uses (16+1)*N jiffies (where N is the number
of algorithms). On my THead C906, I found measurements to be stable
across several reboots, and looked like this:

[    0.047582] cpu0: Unaligned word copy 1728 MB/s, byte copy 402 MB/s, misaligned accesses are fast

I don't have a machine where misaligned accesses are slow, but I'd be
interested to see the results of booting this series if someone did.



Evan Green (2):
  RISC-V: Probe for unaligned access speed
  RISC-V: alternative: Remove feature_probe_func

 Documentation/riscv/hwprobe.rst      |  8 +--
 arch/riscv/errata/thead/errata.c     |  8 ---
 arch/riscv/include/asm/alternative.h |  5 --
 arch/riscv/include/asm/cpufeature.h  |  2 +
 arch/riscv/kernel/Makefile           |  1 +
 arch/riscv/kernel/alternative.c      | 19 -------
 arch/riscv/kernel/copy-noalign.S     | 71 +++++++++++++++++++++++++
 arch/riscv/kernel/copy-noalign.h     | 13 +++++
 arch/riscv/kernel/cpufeature.c       | 78 ++++++++++++++++++++++++++++
 arch/riscv/kernel/smpboot.c          |  3 +-
 10 files changed, 171 insertions(+), 37 deletions(-)
 create mode 100644 arch/riscv/kernel/copy-noalign.S
 create mode 100644 arch/riscv/kernel/copy-noalign.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2023-06-30 21:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 22:20 [PATCH 0/2] RISC-V: Probe for misaligned access speed Evan Green
2023-06-23 22:20 ` [PATCH 1/2] RISC-V: Probe for unaligned " Evan Green
2023-06-25 21:42   ` David Laight
2023-06-26 14:14   ` Conor Dooley
2023-06-27 19:11     ` Evan Green
2023-06-29 14:03       ` Conor Dooley
2023-06-29 23:10         ` Evan Green
2023-06-26 21:42   ` Jessica Clarke
2023-06-27 19:11     ` Evan Green
2023-06-29 12:05       ` David Laight
2023-06-29 23:09         ` Evan Green
2023-06-30  8:29           ` David Laight
2023-06-23 22:20 ` [PATCH 2/2] RISC-V: alternative: Remove feature_probe_func Evan Green
2023-06-26 13:07   ` Conor Dooley
2023-06-30 21:57     ` Evan Green
2023-06-24 10:08 ` [PATCH 0/2] RISC-V: Probe for misaligned access speed Conor Dooley
2023-06-26 19:48   ` Evan Green
2023-06-24 10:22 ` Yangyu Chen
2023-06-26  9:24   ` David Laight
2023-06-26 19:49     ` Evan Green
2023-06-26 19:48   ` Evan Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®