]> git.ipfire.org Git - thirdparty/glibc.git/commit
rtld: cache cpuid results on the stack for intel master
authorFabian Rast <fabian.rast@tum.de>
Thu, 11 Jun 2026 12:30:37 +0000 (14:30 +0200)
committerSunil K Pandey <sunil.k.pandey@intel.com>
Thu, 11 Jun 2026 17:10:38 +0000 (10:10 -0700)
commitdf83fa8813eb53dcb232462a4f6dd00c873115f0
tree4c0f97b4d1c3e5d85f32fa0a39a60201e3d1bf1e
parent8ae37adb211a71a685f0ef3f9b9e18beb439198f
rtld: cache cpuid results on the stack for intel

dl_init_cacheinfo retrieves various information about cache
sizes, using the cpuid instruction on x86.
Previously, the same cpuid leaves were queried multiple times.
This behavior caused intel_check_word to prominently show up in
profiles of dynamic loader startup on the Intel(R) Xeon(R) Gold 6430.
The big performance impact could not be reproduced on other Intel cpus.

This patch reduces the number of cpuid queries on startup
by caching their results on the stack for reuse when searching for a
different cache size value.
This approach does not change the overall design of
the cache enumeration code (repeated calls to handle_* functions).
The values are cached on the stack instead of globally (e.g.
in the cpu_features global) because they are never needed after
early initialization.

The cache is only active for Intel cpus, because it has not yet
been shown through benchmarks that it meaningfully improves performance
for other processors.

Signed-off-by: Fabian Rast <fabian.rast@tum.de>
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
sysdeps/x86/dl-cacheinfo.h