public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/15640] New: lll_unlock uses atomic compare and swap to release a lock
@ 2013-06-17 20:25 adeb at nvidia dot com
  2013-06-17 20:27 ` [Bug nptl/15640] The ARM port of " adeb at nvidia dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: adeb at nvidia dot com @ 2013-06-17 20:25 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-06-13  9:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17 20:25 [Bug nptl/15640] New: lll_unlock uses atomic compare and swap to release a lock adeb at nvidia dot com
2013-06-17 20:27 ` [Bug nptl/15640] The ARM port of " adeb at nvidia dot com
2013-06-18 16:40 ` adeb at nvidia dot com
2013-06-18 20:56 ` chris_s_jones at yahoo dot com
2013-07-11 23:22 ` dtemirbulatov at gmail dot com
2013-07-15 21:35 ` adeb at nvidia dot com
2013-07-15 21:38 ` adeb at nvidia dot com
2013-07-25 18:55 ` dtemirbulatov at gmail dot com
2013-07-29 21:08 ` adeb at nvidia dot com
2013-08-02 17:56 ` dtemirbulatov at gmail dot com
2013-09-19  6:53 ` maxim.kuvyrkov at gmail dot com
2014-06-13  9:52 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).