This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/15640] New: lll_unlock uses atomic compare and swap to release a lock
- From: "adeb at nvidia dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 17 Jun 2013 20:25:45 +0000
- Subject: [Bug nptl/15640] New: lll_unlock uses atomic compare and swap to release a lock
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=15640
Bug ID: 15640
Summary: lll_unlock uses atomic compare and swap to release a
lock
Product: glibc
Version: unspecified
Status: NEW
Severity: enhancement
Priority: P2
Component: nptl
Assignee: unassigned at sourceware dot org
Reporter: adeb at nvidia dot com
CC: drepper.fsp at gmail dot com
The arm implementation of lll_unlock uses atomic compare and swap to release a
lock. This is because the macro atomic_exchange_rel, in include/atomic.h, gets
defined to atomic_exchange_acq, which uses atomic compare and swap.
Releasing a lock would simply require a dmb followed by a simple store. The
benefit would be a bit of performance, in the case when a thread A running on
core 0 trying to acquire a lock competes with a thread B running on core 1
trying to release a lock. Since releasing a lock is currently an atomic compare
and swap, it may fail dut to contention with thread A. However, thread A can't
enter critical section unless thread B releases the lock.
In the current implementation of lock acquisition the atomic compare and swap
sequence is repeated twice before making a futex wait system call. Hence, in
the worst case lock release could fail atmost twice.
If on the other hand, a dmb followed by a normal store sequence had been used
for releasing the lock. Then the store being a normal store would always
succeed. However, even in this case the line could be snooped away by another
core, but that would result in the store being visible a little later.
--
You are receiving this mail because:
You are on the CC list for the bug.