Relevant commits already backported; skipped from this sync: - elf: handle addition overflow in _dl_find_object_update_1 [BZ #32245] (glibc-RHEL-119398.patch) - Avoid uninitialized result in sem_open when file does not exist (glibc-RHEL-119392-1.patch) - Rename new tst-sem17 test to tst-sem18 (glibc-RHEL-119392-2.patch) - nss: Group merge does not react to ERANGE during merge (bug 33361) (glibc-RHEL-114265.patch) - AArch64: Fix instability in AdvSIMD tan (glibc-RHEL-118273-44.patch) RPM-Changelog: - Sync with upstream branch release/2.39/master (RHEL-126766) - Upstream commit: ce65d944e38a20cb70af2a48a4b8aa5d8fabe1cc - posix: Reset wordexp_t fields with WRDE_REUSE (CVE-2025-15281 / BZ 33814) - resolv: Fix NSS DNS backend for getnetbyaddr (CVE-2026-0915) - memalign: reinstate alignment overflow check (CVE-2026-0861) - support: Exit on consistency check failure in resolv_response_add_name - support: Fix FILE * leak in check_for_unshare_hints in test-container - sprof: fix -Wformat warnings on 32-bit hosts - sprof: check pread size and offset for overflow - getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465] - nptl: Optimize trylock for high cache contention workloads (BZ #33704) - ppc64le: Power 10 rawmemchr clobbers v20 (bug #33091) - ppc64le: Restore optimized strncmp for power10 - ppc64le: Restore optimized strcmp for power10 - AArch64: Optimise SVE scalar callbacks - aarch64: fix includes in SME tests - aarch64: fix cfi directives around __libc_arm_za_disable - aarch64: tests for SME - aarch64: clear ZA state of SME before clone and clone3 syscalls - aarch64: define macro for calling __libc_arm_za_disable - aarch64: update tests for SME - aarch64: Disable ZA state of SME in setjmp and sigsetjmp - linux: Also check pkey_get for ENOSYS on tst-pkey (BZ 31996) - aarch64: Do not link conform tests with -Wl,-z,force-bti (bug 33601) - x86: fix wmemset ifunc stray '!' (bug 33542) - x86: Detect Intel Nova Lake Processor - x86: Detect Intel Wildcat Lake Processor Resolves: RHEL-126766 Resolves: RHEL-45143 Resolves: RHEL-45145 Resolves: RHEL-142786 Resolves: RHEL-141852 Resolves: RHEL-141733
45 lines
1.6 KiB
Diff
45 lines
1.6 KiB
Diff
commit ae5fb9355918811679fa7ee01f1f41cea280b615
|
|
Author: Sunil K Pandey <sunil.k.pandey@intel.com>
|
|
Date: Tue Dec 9 08:57:44 2025 -0800
|
|
|
|
nptl: Optimize trylock for high cache contention workloads (BZ #33704)
|
|
|
|
Check lock availability before acquisition to reduce cache line
|
|
bouncing. Significantly improves trylock throughput on multi-core
|
|
systems under heavy contention.
|
|
|
|
Tested on x86_64.
|
|
|
|
Fixes BZ #33704.
|
|
|
|
Co-authored-by: Alex M Wells <alex.m.wells@intel.com>
|
|
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
|
|
(cherry picked from commit 63716823dbad9482e09972907ae98e9cb00f9b86)
|
|
|
|
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
|
|
index 720c103f3f1f92f7..6cf47403dd6a40fe 100644
|
|
--- a/nptl/pthread_mutex_trylock.c
|
|
+++ b/nptl/pthread_mutex_trylock.c
|
|
@@ -48,7 +48,8 @@ ___pthread_mutex_trylock (pthread_mutex_t *mutex)
|
|
return 0;
|
|
}
|
|
|
|
- if (lll_trylock (mutex->__data.__lock) == 0)
|
|
+ if (atomic_load_relaxed (&(mutex->__data.__lock)) == 0
|
|
+ && lll_trylock (mutex->__data.__lock) == 0)
|
|
{
|
|
/* Record the ownership. */
|
|
mutex->__data.__owner = id;
|
|
@@ -71,7 +72,10 @@ ___pthread_mutex_trylock (pthread_mutex_t *mutex)
|
|
/*FALL THROUGH*/
|
|
case PTHREAD_MUTEX_ADAPTIVE_NP:
|
|
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
|
- if (lll_trylock (mutex->__data.__lock) != 0)
|
|
+ /* Mutex type is already loaded, lock check overhead should
|
|
+ be minimal. */
|
|
+ if (atomic_load_relaxed (&(mutex->__data.__lock)) != 0
|
|
+ || lll_trylock (mutex->__data.__lock) != 0)
|
|
break;
|
|
|
|
/* Record the ownership. */
|