From ab75685a6e262907bc02a369d487385323d22f12 Mon Sep 17 00:00:00 2001 From: Jiamei Xie Date: Thu, 4 Jun 2026 16:33:08 +0800 Subject: [PATCH] Backport Hygon model 0x8 support and NT threshold adjustment --- ...Prefer_No_AVX512-for-Hygon-model-0x8.patch | 35 ++++++++++++++++ ...on-temporal-copy-threshold-for-Hygon.patch | 42 +++++++++++++++++++ glibc.spec | 8 +++- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 0001-x86-Enable-Prefer_No_AVX512-for-Hygon-model-0x8.patch create mode 100644 0002-x86-Lower-non-temporal-copy-threshold-for-Hygon.patch diff --git a/0001-x86-Enable-Prefer_No_AVX512-for-Hygon-model-0x8.patch b/0001-x86-Enable-Prefer_No_AVX512-for-Hygon-model-0x8.patch new file mode 100644 index 0000000..dad0756 --- /dev/null +++ b/0001-x86-Enable-Prefer_No_AVX512-for-Hygon-model-0x8.patch @@ -0,0 +1,35 @@ +From 007a45e00fe4b12685c6216bcb6c390b41b825ba Mon Sep 17 00:00:00 2001 +From: xiejiamei +Date: Wed, 29 Apr 2026 08:20:30 +0000 +Subject: [PATCH 1/2] x86: Enable Prefer_No_AVX512 for Hygon model 0x8 + +Extend the Prefer_No_AVX512 tuning to cover Hygon model 0x8. + +Benchmarks on Hygon platforms show that EVEX implementations +are often more profitable than AVX512 paths. The existing logic +already enables Prefer_No_AVX512 for model 0x7. Apply the same +preference to model 0x8 to ensure consistent IFUNC selection +behavior across newer Hygon processors. + +Signed-off-by: xiejiamei +Reviewed-by: H.J. Lu +--- + sysdeps/x86/cpu-features.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c +index 272646355e..3b580b69f4 100644 +--- a/sysdeps/x86/cpu-features.c ++++ b/sysdeps/x86/cpu-features.c +@@ -998,7 +998,7 @@ https://www.intel.com/content/www/us/en/support/articles/000059422/processors.ht + cpu_features->preferred[index_arch_AVX_Fast_Unaligned_Load] + &= ~bit_arch_AVX_Fast_Unaligned_Load; + } +- else if (model == 0x7) ++ else if (model == 0x7 || model == 0x8) + { + /* Benchmarks indicate evex can be more profitable on Hygon + hardware than AVX512. */ +-- +2.17.1 + diff --git a/0002-x86-Lower-non-temporal-copy-threshold-for-Hygon.patch b/0002-x86-Lower-non-temporal-copy-threshold-for-Hygon.patch new file mode 100644 index 0000000..67e4ec5 --- /dev/null +++ b/0002-x86-Lower-non-temporal-copy-threshold-for-Hygon.patch @@ -0,0 +1,42 @@ +From 3a1976c3896d2446f59e640940fbcfdb86129325 Mon Sep 17 00:00:00 2001 +From: xiejiamei +Date: Sat, 9 May 2026 14:23:09 +0800 +Subject: [PATCH 2/2] x86: Lower non-temporal copy threshold for Hygon + +Benchmarks on Hygon processors show that the default non-temporal +threshold is higher than ideal for large copy workloads. As a result, +memcpy and memmove may continue to use the temporal copy path for +longer than is beneficial, increasing cache pollution and reducing +throughput for large copies. + +Lower the copy non-temporal threshold to 3/8 of the shared cache size +per thread on Hygon. This allows the non-temporal copy path to be +selected earlier while leaving the memset non-temporal threshold +unchanged. + +Signed-off-by: xiejiamei +--- + sysdeps/x86/dl-cacheinfo.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h +index a7e316b905..e6edf12e88 100644 +--- a/sysdeps/x86/dl-cacheinfo.h ++++ b/sysdeps/x86/dl-cacheinfo.h +@@ -1239,6 +1239,13 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) + if (!CPU_FEATURES_ARCH_P (cpu_features, Avoid_Non_Temporal_Memset)) + memset_non_temporal_threshold = non_temporal_threshold; + ++ /* Hygon benefits from entering the non-temporal copy path earlier. ++ Use 3/8 of the shared cache size per thread to reduce cache ++ pollution and improve throughput for large copies. Keep the memset ++ non-temporal threshold unchanged. */ ++ if (cpu_features->basic.kind == arch_kind_hygon) ++ non_temporal_threshold = shared_per_thread * 3 / 8; ++ + tunable_size = TUNABLE_GET (x86_non_temporal_threshold, long int, NULL); + if (tunable_size > minimum_non_temporal_threshold + && tunable_size <= maximum_non_temporal_threshold) +-- +2.17.1 + diff --git a/glibc.spec b/glibc.spec index 89bb092..78fd08f 100644 --- a/glibc.spec +++ b/glibc.spec @@ -86,7 +86,7 @@ end} Summary: The GNU libc libraries Name: glibc Version: 2.38 -Release: 50%{?dist} +Release: 51%{?dist} License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and ISC and Public Domain and GFDL URL: http://www.gnu.org/software/glibc/ @@ -333,6 +333,8 @@ Patch0233: 0001-memalign-reinstate-alignment-overflow-check-CVE-2026.patch Patch0234: 0001-resolv-Fix-NSS-DNS-backend-for-getnetbyaddr-CVE-2026.patch Patch0235: 0001-posix-Reset-wordexp_t-fields-with-WRDE_REUSE-CVE-202.patch Patch0236: x86-Fix-for-cache-computation-on-Hygon-under-hypervi.patch +Patch0237: 0001-x86-Enable-Prefer_No_AVX512-for-Hygon-model-0x8.patch +Patch0238: 0002-x86-Lower-non-temporal-copy-threshold-for-Hygon.patch Patch3000: glibc-python3.patch Patch3001: glibc-disable-werror-tst-realloc.patch @@ -1270,6 +1272,10 @@ update_gconv_modules_cache () %endif %changelog +* Thu Jun 04 2026 xiejiamei - 2.38-51 +- [Type] sync +- [DESC] Backport Hygon model 0x8 support and NT threshold adjustment + * Wed Mar 25 2026 Peng Fan - 2.38-50 - [Type] sync - [DESC] LoongArch: Sync from glibc upstream -- Gitee