[PATCH] AArch64: Check kernel version for SVE ifuncs

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Mar 14 14:42:41 GMT 2024


Hi Florian,

> Given that the existing SVE users have not complained about this, is it
> really a good idea to disable SVE string functions for them?  Not
> everyone interleaves system calls and string functions in inner loops.

People have found significant regressions when trying the SVE memcpy [1],
the kernel commit mentions 70% overhead in microbenchmarks [2].

Also distros appear to use a wide range of kernel versions. I've seen the
same GLIBC version used with 5.11 kernel all the way up to 6.5 in the
same version of a distro - and these are all standard installations...

Hence we need some kind of workaround to deal with old kernels before
adding more uses of SVE (new SVE ifuncs or backports of existing ones).

> +/* Parse kernel version without calling any library functions.
> +   Allow 2 digits for kernel version and 3 digits for major version,
> +   separated by '.': "kk.mmm.".
> +   Return kernel version * 1000 + major version, or -1 on failure.  */

> I think you should parse the versions you exclude because you know their
> syntax.  We tried to predict the layout of future kernel version strings
> before and failed.

Yes that is a good idea. So we could just scan for "k.m." format and if it doesn't
match or if uname fails, treat it like a new kernel. It's not a correctness issue,
so if someone uses a different format or blocks uname() in a container then it's
fine to assume it is a new kernel and enable the SVE ifuncs.

Cheers,
Wilco


[1] https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1999551/comments/45
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm64/kernel/fpsimd.c?id=8c845e2731041f0fdf9287dea80b039b26332c9f


More information about the Libc-alpha mailing list