From 9976c2c0e140745f3d3e1eba6f7a6fff6a09d10a Mon Sep 17 00:00:00 2001 From: Doug Core Date: Mon, 7 Aug 2023 21:15:04 -0400 Subject: [PATCH] Disable aligned chunk scanning code added to glibc 2.38 by commits 24cdd6c71debfd10a9f7cb217fe2a2c4c486ed6f and e5524ef335dc8e28d64cc376d57c219e566fcf53 pending upstream fix. This scanning causes a serious performance regression for applications using posix_memalign. Disabling it reverts to the same code path as glibc 2.37. https://bugs.archlinux.org/task/79300 https://sourceware.org/pipermail/libc-alpha/2023-August/150653.html https://sourceware.org/bugzilla/show_bug.cgi?id=30723 --- PKGBUILD | 12 ++++- disable-aligned-chunk-scanning.patch | 39 ++++++++++++++++ remove-aligned-chunk-scanning-tests.patch | 54 +++++++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 disable-aligned-chunk-scanning.patch create mode 100644 remove-aligned-chunk-scanning-tests.patch diff --git a/PKGBUILD b/PKGBUILD index d5c5215..9b27503 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,7 +10,7 @@ pkgbase=glibc pkgname=(glibc lib32-glibc) pkgver=2.38 _commit=36f2487f13e3540be9ee0fb51876b1da72176d3f -pkgrel=2 +pkgrel=3 arch=(x86_64) url='https://www.gnu.org/software/libc' license=(GPL LGPL) @@ -23,6 +23,8 @@ source=(git+https://sourceware.org/git/glibc.git#commit=${_commit} sdt.h sdt-config.h reenable_DT_HASH.patch PATCH-nscd-Do-not-rebuild-getaddrinfo-bug-30709.patch + disable-aligned-chunk-scanning.patch + remove-aligned-chunk-scanning-tests.patch ) validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar @@ -33,7 +35,9 @@ b2sums=('SKIP' 'a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e' '214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678' '35e03ed912e1b0cd23783ab83ce919412885c141344905b8b67bbad4a86c48cf3e893806060e48d5737514ff80cea0b58b0e1f15707c32224579c416dcd810c0' - '2a83dad4bcca543a5a85e91ebbe2bbccb4f863044d9e6e65806be0ea43ba70dd4e1e76e1548f9d189e996d4fcda0afc75efebdc9431fe10f2b66d3d2e878615b') + '2a83dad4bcca543a5a85e91ebbe2bbccb4f863044d9e6e65806be0ea43ba70dd4e1e76e1548f9d189e996d4fcda0afc75efebdc9431fe10f2b66d3d2e878615b' + '2bb97b5e5c327ba3f4e92a9330249ce9e96ae39781d50d584869eea974204567db965e24242df3ec72a716febeb8180c54c740a2e2023f609aac3aaa5cb717ea' + '0d1c5b89369907805b2d13e1b85d0b8bd8cdb8b142f221a01bbc2949ba246539e165a714f37b9092e6c868211cd424d5545047e07dc4295f82832bf3300ed0a5') prepare() { mkdir -p glibc-build lib32-glibc-build @@ -47,6 +51,10 @@ prepare() { patch -Np1 -i "${srcdir}"/reenable_DT_HASH.patch patch -Np1 < ../PATCH-nscd-Do-not-rebuild-getaddrinfo-bug-30709.patch + + patch -Np1 < ../disable-aligned-chunk-scanning.patch + + patch -Np1 < ../remove-aligned-chunk-scanning-tests.patch } build() { diff --git a/disable-aligned-chunk-scanning.patch b/disable-aligned-chunk-scanning.patch new file mode 100644 index 0000000..907413b --- /dev/null +++ b/disable-aligned-chunk-scanning.patch @@ -0,0 +1,39 @@ +From e7d52f07d46e4268a53ce4af13c2f670b746f494 Mon Sep 17 00:00:00 2001 +From: Doug Core +Date: Mon, 7 Aug 2023 15:47:20 -0400 +Subject: [PATCH 1/2] Disable aligned chunk scanning code added to glibc 2.38 + by commits 24cdd6c71debfd10a9f7cb217fe2a2c4c486ed6f and + e5524ef335dc8e28d64cc376d57c219e566fcf53 pending upstream fix. This scanning + causes a serious performance regression for applications using + posix_memalign. Disabling it reverts to the same code path as glibc 2.37. + +https://bugs.archlinux.org/task/79300 +https://sourceware.org/pipermail/libc-alpha/2023-August/150653.html +https://sourceware.org/bugzilla/show_bug.cgi?id=30723 +--- + malloc/malloc.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/malloc/malloc.c b/malloc/malloc.c +index e2f1a615a4..97b41bec85 100644 +--- a/malloc/malloc.c ++++ b/malloc/malloc.c +@@ -5075,7 +5075,14 @@ _int_memalign (mstate av, size_t alignment, size_t bytes) + and unlikely to meet our alignment requirements. We have not done + any experimentation with searching for aligned fastbins. */ + +- if (av != NULL) ++ /* Disable aligned chunk scanning code added to glibc 2.38 by commits 24cdd6c71debfd10a9f7cb217fe2a2c4c486ed6f ++ and e5524ef335dc8e28d64cc376d57c219e566fcf53 pending upstream fix. This scanning causes a serious performance ++ regression for applications using posix_memalign. Disabling it reverts to the same code path as glibc 2.37. ++ ++ https://bugs.archlinux.org/task/79300 ++ https://sourceware.org/pipermail/libc-alpha/2023-August/150653.html ++ https://sourceware.org/bugzilla/show_bug.cgi?id=30723 */ ++ if (0) + { + int first_bin_index; + int first_largebin_index; +-- +2.41.0 + diff --git a/remove-aligned-chunk-scanning-tests.patch b/remove-aligned-chunk-scanning-tests.patch new file mode 100644 index 0000000..e301e72 --- /dev/null +++ b/remove-aligned-chunk-scanning-tests.patch @@ -0,0 +1,54 @@ +From 9ccd5b462226848897deebff7d9db8e2858f5e7b Mon Sep 17 00:00:00 2001 +From: Doug Core +Date: Mon, 7 Aug 2023 20:09:15 -0400 +Subject: [PATCH 2/2] Remove tests that were added for the disabled aligned + chunk scanning code. + +--- + malloc/Makefile | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +diff --git a/malloc/Makefile b/malloc/Makefile +index c1db3347d8..e0ec570aa4 100644 +--- a/malloc/Makefile ++++ b/malloc/Makefile +@@ -43,8 +43,6 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \ + tst-tcfree1 tst-tcfree2 tst-tcfree3 \ + tst-safe-linking \ + tst-mallocalign1 \ +- tst-memalign-2 \ +- tst-memalign-3 \ + tst-aligned-alloc + + tests-static := \ +@@ -74,7 +72,7 @@ test-srcs = tst-mtrace + # with MALLOC_CHECK_=3 because they expect a specific failure. + tests-exclude-malloc-check = tst-malloc-check tst-malloc-usable \ + tst-mxfast tst-safe-linking \ +- tst-compathooks-off tst-compathooks-on tst-memalign-2 tst-memalign-3 \ ++ tst-compathooks-off tst-compathooks-on \ + tst-mallocfork2 \ + tst-mallocfork3 \ + tst-malloc-tcache-leak +@@ -125,8 +123,6 @@ tests-exclude-mcheck = tst-mallocstate \ + tst-malloc-usable-tunables \ + tst-malloc_info \ + tst-compathooks-off tst-compathooks-on \ +- tst-memalign-2 \ +- tst-memalign-3 \ + tst-mxfast \ + tst-mallocfork2 \ + tst-mallocfork3 +@@ -353,9 +349,6 @@ $(objpfx)tst-malloc_info-malloc-check: $(shared-thread-library) + $(objpfx)tst-mallocfork2-malloc-check: $(shared-thread-library) + $(objpfx)tst-malloc_info-malloc-hugetlb1: $(shared-thread-library) + $(objpfx)tst-malloc_info-malloc-hugetlb2: $(shared-thread-library) +-$(objpfx)tst-memalign-3: $(shared-thread-library) +-$(objpfx)tst-memalign-3-malloc-hugetlb1: $(shared-thread-library) +-$(objpfx)tst-memalign-3-malloc-hugetlb2: $(shared-thread-library) + + tst-compathooks-on-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so + tst-compathooks-on-mcheck-ENV = LD_PRELOAD=$(objpfx)libc_malloc_debug.so +-- +2.41.0 + -- 2.41.0