On Mon, 2014-07-21 at 11:24 -0400, Waiman Long wrote:
This patch adds code to do optimistic spinning for the FUTEX_SPIN_LOCKPerhaps we could introduce a "CONFIG_FUTEX_SPIN_ON_OWNER" that depends
primitive on the futex value when the lock owner is running. It is
the same optimistic spinning technique that is done in the mutex and
rw semaphore code to improve their performance especially on large
systems with large number of CPUs. When the lock owner is not running,
the spinning tasks will go to sleep.
on SMP and ARCH_SUPPORTS_ATOMIC_RMW?
There is 2 major advantages of doing optimistic spinning here:And this would have to be updated to
1) It eliminates the context switching latency and overhead (at
least a few us) associated with sleeping and wakeup.
2) It eliminates most of the need to call futex(2) with
FUTEX_SPIN_UNLOCK as spinning is done without the need to set
the FUTEX_WAITERS bit.
struct futex_q_head {
struct list_head hnode;
struct list_head waitq;
union futex_key key;
+ struct optimistic_spin_queue *osq;
+ struct optimistic_spin_queue osq;
given the recent changes to the osq lock.