Skip to content

x86: Optimize memchr() for x86-64

Yu-Jen Chang linux-hardening linux-um lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86/lib: Optimize memchr()arch/x86/include/asm/string_64.h arch/x86/lib/Makefile arch/x86/lib/string_64.c+82 -06 replies
2/2x86/um: Use x86_64-optimized memchrarch/x86/um/Makefile+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] x86: Optimize memchr() for x86-64

*** BLURB HERE ***
These patch series add an optimized "memchr()" for x86-64 and USER-MODE LINUX (UML).

There exists an assemebly implementation for x86-32. However, for x86-64, there isn't any optimized version. We implement word-wise comparison so that 8 characters can be compared at the same time on x86-64 CPU. The optimized “memchr()” is nearly 4x faster than the orginal implementation for long strings.

We test the optimized “memchr()” in UML and also recompile the 5.18 Kernel with the optimized “memchr()”. They run correctly.

In this patch we add a new file "string_64.c", which only contains "memchr()". We can add more optimized string functions in it in the future.

Yu-Jen Chang (2):
x86/lib: Optimize memchr()
x86/um: Use x86_64-optimized memchr

 arch/x86/include/asm/string_64.h |  3 ++
 arch/x86/lib/Makefile            |  1 +
 arch/x86/lib/string_64.c         | 78 ++++++++++++++++++++++++++++++++
 arch/x86/um/Makefile             |  2 +-
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/lib/string_64.c
Signature · 1 line
2.25.1