HomeFreeBSD

lib/libc/amd64/string/strcmp.S: add baseline implementation

Description

lib/libc/amd64/string/strcmp.S: add baseline implementation

This is the most complicated one so far. The basic idea is to process
the bulk of the string in aligned blocks of 16 bytes such that one
string runs ahead and the other runs behind. The string that runs ahead
is checked for NUL bytes, the one that runs behind is compared with the
corresponding chunk of the string that runs ahead. This trades an extra
load per iteration for the very complicated block-reassembly needed in
the other implementations (bionic, glibc). On the flip side, we need
two code paths depending on the relative alignment of the two buffers.

The initial part of the string is compared directly if it is known not
to cross a page boundary. Otherwise, a complex slow path to avoid
crossing into unmapped memory commences.

Performance-wise we beat bionic for misaligned strings (i.e. the strings
do not share an alignment offset) and reach comparable performance for
aligned strings. glibc is a bit better as it has a special kernel for
AVX-512, where this stuff is a bit easier to do.

Sponsored by: The FreeBSD Foundation
Tested by: developers@, exp-run
Approved by: mjg
MFC after: 1 month
MFC to: stable/14
PR: 275785
Differential Revision: https://reviews.freebsd.org/D41971

(cherry picked from commit bca25680b91b3bea7faef615765806a04634eb23)

Details

Provenance
fuzAuthored on Sep 16 2023, 5:29 AM
Differential Revision
D41971: lib/libc/amd64/string/strcmp.S: add baseline implementation
Parents
rG8788c3d3fa9d: sysctl vm.objects/vm.swap_objects: do not fill vnode info if jailed
Branches
Unknown
Tags
Unknown