提交 4d9d951e 编写于 作者: J Jason Low 提交者: Ingo Molnar

locking/spinlocks/mcs: Introduce and use init macro and function for osq locks

Currently, we initialize the osq lock by directly setting the lock's values. It
would be preferable if we use an init macro to do the initialization like we do
with other locks.

This patch introduces and uses a macro and function for initializing the osq lock.
Signed-off-by: NJason Low <jason.low2@hp.com>
Signed-off-by: NPeter Zijlstra <peterz@infradead.org>
Cc: Scott Norton <scott.norton@hp.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Waiman Long <waiman.long@hp.com>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Link: http://lkml.kernel.org/r/1405358872-3732-4-git-send-email-jason.low2@hp.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 90631822
...@@ -16,4 +16,12 @@ struct optimistic_spin_queue { ...@@ -16,4 +16,12 @@ struct optimistic_spin_queue {
atomic_t tail; atomic_t tail;
}; };
/* Init macro and function. */
#define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) }
static inline void osq_lock_init(struct optimistic_spin_queue *lock)
{
atomic_set(&lock->tail, OSQ_UNLOCKED_VAL);
}
#endif #endif
...@@ -69,7 +69,7 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) ...@@ -69,7 +69,7 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
__RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \
LIST_HEAD_INIT((name).wait_list), \ LIST_HEAD_INIT((name).wait_list), \
NULL, /* owner */ \ NULL, /* owner */ \
{ ATOMIC_INIT(OSQ_UNLOCKED_VAL) } /* osq */ \ OSQ_LOCK_UNLOCKED /* osq */ \
__RWSEM_DEP_MAP_INIT(name) } __RWSEM_DEP_MAP_INIT(name) }
#else #else
#define __RWSEM_INITIALIZER(name) \ #define __RWSEM_INITIALIZER(name) \
......
...@@ -60,7 +60,7 @@ __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key) ...@@ -60,7 +60,7 @@ __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key)
INIT_LIST_HEAD(&lock->wait_list); INIT_LIST_HEAD(&lock->wait_list);
mutex_clear_owner(lock); mutex_clear_owner(lock);
#ifdef CONFIG_MUTEX_SPIN_ON_OWNER #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
atomic_set(&lock->osq.tail, OSQ_UNLOCKED_VAL); osq_lock_init(&lock->osq);
#endif #endif
debug_mutex_init(lock, name, key); debug_mutex_init(lock, name, key);
......
...@@ -84,7 +84,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, ...@@ -84,7 +84,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name,
INIT_LIST_HEAD(&sem->wait_list); INIT_LIST_HEAD(&sem->wait_list);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
sem->owner = NULL; sem->owner = NULL;
atomic_set(&sem->osq.tail, OSQ_UNLOCKED_VAL); osq_lock_init(&sem->osq);
#endif #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册