This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/15640] New: lll_unlock uses atomic compare and swap to release a lock

            Bug ID: 15640
           Summary: lll_unlock uses atomic compare and swap to release a
           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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]