[PATCH v3] nptl: Optimize trylock for high cache contention workloads (BZ #33704)

Florian Weimer fweimer@redhat.com
Tue Dec 16 23:06:35 GMT 2025


* Yann Droneaud:

> as lll_trylock() is a macro, could the relaxed load be inserted into
> it, providing the improvement to other user of lll_trylock() ?

Direct CAS for an uncontended lock is better because it avoids a shared
→ exclusive cacheline transition, so it's less clear if the change is
beneficial at the lll_trylock layer.  This is not a concern for
pthread_mutex_trylock because it reads the type member first, which is
with some likelihood on the same cacheline (but not guaranteed to be).

Thanks,
Florian



More information about the Libc-alpha mailing list