RISC-V Optimized strnlen Implementation For Linux 7.1 Yields Big Speed-Up

RISC-V Optimized strnlen Implementation For Linux 7.1 Yields Big Speed-Up

RISC-V Optimized strnlen Implementation For Linux 7.1 Yields Big Speed-Up

https://www.phoronix.com/news/Linux-7.1-RISC-V-strnlen

Publish Date: 2026-04-09 09:51:00

Source Domain: www.phoronix.com

In addition to RISC-V discontinuing its eXecute In Place “XIP” kernel support for Linux 7.1, there is an optimized strnlen() function coming for Linux 7.1 on RISC-V as well as some other optimized functions.

Feng Jiang with KylinOS wrote a hand-optimized strnlen() implementation for RISC-V with both a generic code path and Zbb-powered version. The strnlen() function used throughout the kernel for safely determining the length of a string is seeing a massive speed-up as a result of the hand-optimized RISC-V Assembly code.

RISC-V Optimized strnlen Implementation For Linux 7.1 Yields Big Speed-Up

Benchmarks are showing as much as a +427.5% improvement with the RISC-V optimized strnlen function appearing at long last.

The strnlen optimization patch is queued into the RISC-V’s “for-next” Git branch ahead of the Linux 7.1 merge window opening next week.

There is also a RISC-V optimized strchr() function too for up to a 7% improvement for finding the first occurence of the character in a string. And the optimized strrchr() for the reverse searching yielding up to a 8% improvement from that hand-written RISC-V Assembly for the Linux kernel.

Source