]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
riscv: lib: add strchr() implementation
authorFeng Jiang <jiangfeng@kylinos.cn>
Sat, 4 Apr 2026 01:28:47 +0000 (19:28 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:42:44 +0000 (18:42 -0600)
commitadf542133960d402f63c976b00e46be4d986d4c3
tree0275334bce9499e0637c94901c7355eeb194733f
parent5ba15d419fab848a3813eb56bbcad00e291fbc49
riscv: lib: add strchr() implementation

Add an assembly implementation of strchr() for RISC-V.

By eliminating stack frame management (prologue/epilogue) and optimizing
the function entries, the assembly version provides significant relative
gains for short strings where the fixed overhead of the C function is
most prominent. As string length increases, performance converges with
the generic C implementation.

Benchmark results (QEMU TCG, rv64):
  Length | Original (MB/s) | Optimized (MB/s) | Improvement
  -------|-----------------|------------------|------------
  1 B    | 21              | 22               | +4.8%
  7 B    | 113             | 121              | +7.1%
  16 B   | 195             | 202              | +3.6%
  512 B  | 376             | 389              | +3.5%
  4096 B | 394             | 393              | -0.3%

Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Tested-by: Joel Stanley <joel@jms.id.au>
Link: https://patch.msgid.link/20260130025018.172925-8-jiangfeng@kylinos.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/string.h
arch/riscv/lib/Makefile
arch/riscv/lib/strchr.S [new file with mode: 0644]
arch/riscv/purgatory/Makefile