2005-04-17 02:20:36 +04:00
|
|
|
/* rwsem.h: R/W semaphores, public interface
|
|
|
|
*
|
|
|
|
* Written by David Howells (dhowells@redhat.com).
|
|
|
|
* Derived from asm-i386/semaphore.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_RWSEM_H
|
|
|
|
#define _LINUX_RWSEM_H
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
2011-01-26 23:05:50 +03:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/spinlock.h>
|
2011-07-27 03:09:06 +04:00
|
|
|
#include <linux/atomic.h>
|
2016-04-07 18:12:26 +03:00
|
|
|
#include <linux/err.h>
|
2014-07-12 01:00:06 +04:00
|
|
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
2014-07-14 21:27:49 +04:00
|
|
|
#include <linux/osq_lock.h>
|
2014-07-12 01:00:06 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct rw_semaphore;
|
|
|
|
|
|
|
|
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
|
|
|
#include <linux/rwsem-spinlock.h> /* use a generic implementation */
|
2016-06-04 08:26:02 +03:00
|
|
|
#define __RWSEM_INIT_COUNT(name) .count = RWSEM_UNLOCKED_VALUE
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
2011-01-26 23:05:56 +03:00
|
|
|
/* All arch specific implementations share the same struct */
|
|
|
|
struct rw_semaphore {
|
2016-06-04 08:26:02 +03:00
|
|
|
atomic_long_t count;
|
locking/rwsem: Support optimistic spinning
We have reached the point where our mutexes are quite fine tuned
for a number of situations. This includes the use of heuristics
and optimistic spinning, based on MCS locking techniques.
Exclusive ownership of read-write semaphores are, conceptually,
just about the same as mutexes, making them close cousins. To
this end we need to make them both perform similarly, and
right now, rwsems are simply not up to it. This was discovered
by both reverting commit 4fc3f1d6 (mm/rmap, migration: Make
rmap_walk_anon() and try_to_unmap_anon() more scalable) and
similarly, converting some other mutexes (ie: i_mmap_mutex) to
rwsems. This creates a situation where users have to choose
between a rwsem and mutex taking into account this important
performance difference. Specifically, biggest difference between
both locks is when we fail to acquire a mutex in the fastpath,
optimistic spinning comes in to play and we can avoid a large
amount of unnecessary sleeping and overhead of moving tasks in
and out of wait queue. Rwsems do not have such logic.
This patch, based on the work from Tim Chen and I, adds support
for write-side optimistic spinning when the lock is contended.
It also includes support for the recently added cancelable MCS
locking for adaptive spinning. Note that is is only applicable
to the xadd method, and the spinlock rwsem variant remains intact.
Allowing optimistic spinning before putting the writer on the wait
queue reduces wait queue contention and provided greater chance
for the rwsem to get acquired. With these changes, rwsem is on par
with mutex. The performance benefits can be seen on a number of
workloads. For instance, on a 8 socket, 80 core 64bit Westmere box,
aim7 shows the following improvements in throughput:
+--------------+---------------------+-----------------+
| Workload | throughput-increase | number of users |
+--------------+---------------------+-----------------+
| alltests | 20% | >1000 |
| custom | 27%, 60% | 10-100, >1000 |
| high_systime | 36%, 30% | >100, >1000 |
| shared | 58%, 29% | 10-100, >1000 |
+--------------+---------------------+-----------------+
There was also improvement on smaller systems, such as a quad-core
x86-64 laptop running a 30Gb PostgreSQL (pgbench) workload for up
to +60% in throughput for over 50 clients. Additionally, benefits
were also noticed in exim (mail server) workloads. Furthermore, no
performance regression have been seen at all.
Based-on-work-from: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
[peterz: rej fixup due to comment patches, sched/rt.h header]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E.McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Scott J Norton" <scott.norton@hp.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Link: http://lkml.kernel.org/r/1399055055.6275.15.camel@buesod1.americas.hpqcorp.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-05-02 22:24:15 +04:00
|
|
|
struct list_head wait_list;
|
2014-07-14 21:27:52 +04:00
|
|
|
raw_spinlock_t wait_lock;
|
2014-07-12 01:00:06 +04:00
|
|
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
2014-07-14 21:27:52 +04:00
|
|
|
struct optimistic_spin_queue osq; /* spinner MCS lock */
|
locking/rwsem: Support optimistic spinning
We have reached the point where our mutexes are quite fine tuned
for a number of situations. This includes the use of heuristics
and optimistic spinning, based on MCS locking techniques.
Exclusive ownership of read-write semaphores are, conceptually,
just about the same as mutexes, making them close cousins. To
this end we need to make them both perform similarly, and
right now, rwsems are simply not up to it. This was discovered
by both reverting commit 4fc3f1d6 (mm/rmap, migration: Make
rmap_walk_anon() and try_to_unmap_anon() more scalable) and
similarly, converting some other mutexes (ie: i_mmap_mutex) to
rwsems. This creates a situation where users have to choose
between a rwsem and mutex taking into account this important
performance difference. Specifically, biggest difference between
both locks is when we fail to acquire a mutex in the fastpath,
optimistic spinning comes in to play and we can avoid a large
amount of unnecessary sleeping and overhead of moving tasks in
and out of wait queue. Rwsems do not have such logic.
This patch, based on the work from Tim Chen and I, adds support
for write-side optimistic spinning when the lock is contended.
It also includes support for the recently added cancelable MCS
locking for adaptive spinning. Note that is is only applicable
to the xadd method, and the spinlock rwsem variant remains intact.
Allowing optimistic spinning before putting the writer on the wait
queue reduces wait queue contention and provided greater chance
for the rwsem to get acquired. With these changes, rwsem is on par
with mutex. The performance benefits can be seen on a number of
workloads. For instance, on a 8 socket, 80 core 64bit Westmere box,
aim7 shows the following improvements in throughput:
+--------------+---------------------+-----------------+
| Workload | throughput-increase | number of users |
+--------------+---------------------+-----------------+
| alltests | 20% | >1000 |
| custom | 27%, 60% | 10-100, >1000 |
| high_systime | 36%, 30% | >100, >1000 |
| shared | 58%, 29% | 10-100, >1000 |
+--------------+---------------------+-----------------+
There was also improvement on smaller systems, such as a quad-core
x86-64 laptop running a 30Gb PostgreSQL (pgbench) workload for up
to +60% in throughput for over 50 clients. Additionally, benefits
were also noticed in exim (mail server) workloads. Furthermore, no
performance regression have been seen at all.
Based-on-work-from: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
[peterz: rej fixup due to comment patches, sched/rt.h header]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E.McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Scott J Norton" <scott.norton@hp.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Link: http://lkml.kernel.org/r/1399055055.6275.15.camel@buesod1.americas.hpqcorp.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-05-02 22:24:15 +04:00
|
|
|
/*
|
|
|
|
* Write owner. Used as a speculative check to see
|
|
|
|
* if the owner is running on the cpu.
|
|
|
|
*/
|
|
|
|
struct task_struct *owner;
|
|
|
|
#endif
|
2011-01-26 23:05:56 +03:00
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
struct lockdep_map dep_map;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-01-26 23:32:01 +03:00
|
|
|
extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
|
|
|
|
extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
|
2016-04-07 18:12:26 +03:00
|
|
|
extern struct rw_semaphore *rwsem_down_write_failed_killable(struct rw_semaphore *sem);
|
2011-01-26 23:32:01 +03:00
|
|
|
extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *);
|
|
|
|
extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
|
2011-01-26 23:06:06 +03:00
|
|
|
|
2011-01-26 23:05:56 +03:00
|
|
|
/* Include the arch specific part */
|
|
|
|
#include <asm/rwsem.h>
|
2011-01-26 23:06:03 +03:00
|
|
|
|
|
|
|
/* In all implementations count != 0 means locked */
|
|
|
|
static inline int rwsem_is_locked(struct rw_semaphore *sem)
|
|
|
|
{
|
2016-06-04 08:26:02 +03:00
|
|
|
return atomic_long_read(&sem->count) != 0;
|
2011-01-26 23:06:03 +03:00
|
|
|
}
|
|
|
|
|
2016-06-04 08:26:02 +03:00
|
|
|
#define __RWSEM_INIT_COUNT(name) .count = ATOMIC_LONG_INIT(RWSEM_UNLOCKED_VALUE)
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
2011-01-26 23:06:00 +03:00
|
|
|
/* Common initializer macros and functions */
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
|
|
|
|
#else
|
|
|
|
# define __RWSEM_DEP_MAP_INIT(lockname)
|
|
|
|
#endif
|
|
|
|
|
2014-07-12 01:00:06 +04:00
|
|
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
2014-07-14 21:27:52 +04:00
|
|
|
#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
|
locking/rwsem: Support optimistic spinning
We have reached the point where our mutexes are quite fine tuned
for a number of situations. This includes the use of heuristics
and optimistic spinning, based on MCS locking techniques.
Exclusive ownership of read-write semaphores are, conceptually,
just about the same as mutexes, making them close cousins. To
this end we need to make them both perform similarly, and
right now, rwsems are simply not up to it. This was discovered
by both reverting commit 4fc3f1d6 (mm/rmap, migration: Make
rmap_walk_anon() and try_to_unmap_anon() more scalable) and
similarly, converting some other mutexes (ie: i_mmap_mutex) to
rwsems. This creates a situation where users have to choose
between a rwsem and mutex taking into account this important
performance difference. Specifically, biggest difference between
both locks is when we fail to acquire a mutex in the fastpath,
optimistic spinning comes in to play and we can avoid a large
amount of unnecessary sleeping and overhead of moving tasks in
and out of wait queue. Rwsems do not have such logic.
This patch, based on the work from Tim Chen and I, adds support
for write-side optimistic spinning when the lock is contended.
It also includes support for the recently added cancelable MCS
locking for adaptive spinning. Note that is is only applicable
to the xadd method, and the spinlock rwsem variant remains intact.
Allowing optimistic spinning before putting the writer on the wait
queue reduces wait queue contention and provided greater chance
for the rwsem to get acquired. With these changes, rwsem is on par
with mutex. The performance benefits can be seen on a number of
workloads. For instance, on a 8 socket, 80 core 64bit Westmere box,
aim7 shows the following improvements in throughput:
+--------------+---------------------+-----------------+
| Workload | throughput-increase | number of users |
+--------------+---------------------+-----------------+
| alltests | 20% | >1000 |
| custom | 27%, 60% | 10-100, >1000 |
| high_systime | 36%, 30% | >100, >1000 |
| shared | 58%, 29% | 10-100, >1000 |
+--------------+---------------------+-----------------+
There was also improvement on smaller systems, such as a quad-core
x86-64 laptop running a 30Gb PostgreSQL (pgbench) workload for up
to +60% in throughput for over 50 clients. Additionally, benefits
were also noticed in exim (mail server) workloads. Furthermore, no
performance regression have been seen at all.
Based-on-work-from: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
[peterz: rej fixup due to comment patches, sched/rt.h header]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E.McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Scott J Norton" <scott.norton@hp.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Link: http://lkml.kernel.org/r/1399055055.6275.15.camel@buesod1.americas.hpqcorp.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-05-02 22:24:15 +04:00
|
|
|
#else
|
2014-07-14 21:27:52 +04:00
|
|
|
#define __RWSEM_OPT_INIT(lockname)
|
locking/rwsem: Support optimistic spinning
We have reached the point where our mutexes are quite fine tuned
for a number of situations. This includes the use of heuristics
and optimistic spinning, based on MCS locking techniques.
Exclusive ownership of read-write semaphores are, conceptually,
just about the same as mutexes, making them close cousins. To
this end we need to make them both perform similarly, and
right now, rwsems are simply not up to it. This was discovered
by both reverting commit 4fc3f1d6 (mm/rmap, migration: Make
rmap_walk_anon() and try_to_unmap_anon() more scalable) and
similarly, converting some other mutexes (ie: i_mmap_mutex) to
rwsems. This creates a situation where users have to choose
between a rwsem and mutex taking into account this important
performance difference. Specifically, biggest difference between
both locks is when we fail to acquire a mutex in the fastpath,
optimistic spinning comes in to play and we can avoid a large
amount of unnecessary sleeping and overhead of moving tasks in
and out of wait queue. Rwsems do not have such logic.
This patch, based on the work from Tim Chen and I, adds support
for write-side optimistic spinning when the lock is contended.
It also includes support for the recently added cancelable MCS
locking for adaptive spinning. Note that is is only applicable
to the xadd method, and the spinlock rwsem variant remains intact.
Allowing optimistic spinning before putting the writer on the wait
queue reduces wait queue contention and provided greater chance
for the rwsem to get acquired. With these changes, rwsem is on par
with mutex. The performance benefits can be seen on a number of
workloads. For instance, on a 8 socket, 80 core 64bit Westmere box,
aim7 shows the following improvements in throughput:
+--------------+---------------------+-----------------+
| Workload | throughput-increase | number of users |
+--------------+---------------------+-----------------+
| alltests | 20% | >1000 |
| custom | 27%, 60% | 10-100, >1000 |
| high_systime | 36%, 30% | >100, >1000 |
| shared | 58%, 29% | 10-100, >1000 |
+--------------+---------------------+-----------------+
There was also improvement on smaller systems, such as a quad-core
x86-64 laptop running a 30Gb PostgreSQL (pgbench) workload for up
to +60% in throughput for over 50 clients. Additionally, benefits
were also noticed in exim (mail server) workloads. Furthermore, no
performance regression have been seen at all.
Based-on-work-from: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
[peterz: rej fixup due to comment patches, sched/rt.h header]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E.McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Scott J Norton" <scott.norton@hp.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Link: http://lkml.kernel.org/r/1399055055.6275.15.camel@buesod1.americas.hpqcorp.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-05-02 22:24:15 +04:00
|
|
|
#endif
|
2011-01-26 23:06:00 +03:00
|
|
|
|
2014-07-14 21:27:52 +04:00
|
|
|
#define __RWSEM_INITIALIZER(name) \
|
2016-06-04 08:26:02 +03:00
|
|
|
{ __RWSEM_INIT_COUNT(name), \
|
2014-07-14 21:27:52 +04:00
|
|
|
.wait_list = LIST_HEAD_INIT((name).wait_list), \
|
|
|
|
.wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
|
|
|
|
__RWSEM_OPT_INIT(name) \
|
|
|
|
__RWSEM_DEP_MAP_INIT(name) }
|
|
|
|
|
2011-01-26 23:06:00 +03:00
|
|
|
#define DECLARE_RWSEM(name) \
|
|
|
|
struct rw_semaphore name = __RWSEM_INITIALIZER(name)
|
|
|
|
|
|
|
|
extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
|
|
|
|
struct lock_class_key *key);
|
|
|
|
|
|
|
|
#define init_rwsem(sem) \
|
|
|
|
do { \
|
|
|
|
static struct lock_class_key __key; \
|
|
|
|
\
|
|
|
|
__init_rwsem((sem), #sem, &__key); \
|
|
|
|
} while (0)
|
|
|
|
|
2013-08-30 18:05:22 +04:00
|
|
|
/*
|
|
|
|
* This is the same regardless of which rwsem implementation that is being used.
|
|
|
|
* It is just a heuristic meant to be called by somebody alreadying holding the
|
|
|
|
* rwsem to see if somebody from an incompatible type is wanting access to the
|
|
|
|
* lock.
|
|
|
|
*/
|
|
|
|
static inline int rwsem_is_contended(struct rw_semaphore *sem)
|
|
|
|
{
|
|
|
|
return !list_empty(&sem->wait_list);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* lock for reading
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern void down_read(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* trylock for reading -- returns 1 if successful, 0 if contention
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern int down_read_trylock(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* lock for writing
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern void down_write(struct rw_semaphore *sem);
|
2016-04-07 18:12:31 +03:00
|
|
|
extern int __must_check down_write_killable(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* trylock for writing -- returns 1 if successful, 0 if contention
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern int down_write_trylock(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* release a read lock
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern void up_read(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* release a write lock
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern void up_write(struct rw_semaphore *sem);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* downgrade write lock to read lock
|
|
|
|
*/
|
2006-07-03 11:24:53 +04:00
|
|
|
extern void downgrade_write(struct rw_semaphore *sem);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
/*
|
2006-07-10 15:44:02 +04:00
|
|
|
* nested locking. NOTE: rwsems are not allowed to recurse
|
|
|
|
* (which occurs if the same task tries to acquire the same
|
|
|
|
* lock instance multiple times), but multiple locks of the
|
|
|
|
* same lock class might be taken, if the order of the locks
|
|
|
|
* is always the same. This ordering rule can be expressed
|
|
|
|
* to lockdep via the _nested() APIs, but enumerating the
|
|
|
|
* subclasses that are used. (If the nesting relationship is
|
|
|
|
* static then another method for expressing nested locking is
|
|
|
|
* the explicit definition of lock class keys and the use of
|
|
|
|
* lockdep_set_class() at lock initialization time.
|
2014-07-31 00:41:55 +04:00
|
|
|
* See Documentation/locking/lockdep-design.txt for more details.)
|
2006-07-03 11:24:53 +04:00
|
|
|
*/
|
|
|
|
extern void down_read_nested(struct rw_semaphore *sem, int subclass);
|
|
|
|
extern void down_write_nested(struct rw_semaphore *sem, int subclass);
|
2016-05-26 07:04:58 +03:00
|
|
|
extern int down_write_killable_nested(struct rw_semaphore *sem, int subclass);
|
2013-01-12 02:31:56 +04:00
|
|
|
extern void _down_write_nest_lock(struct rw_semaphore *sem, struct lockdep_map *nest_lock);
|
|
|
|
|
|
|
|
# define down_write_nest_lock(sem, nest_lock) \
|
|
|
|
do { \
|
|
|
|
typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
|
|
|
|
_down_write_nest_lock(sem, &(nest_lock)->dep_map); \
|
|
|
|
} while (0);
|
|
|
|
|
2011-09-22 08:43:05 +04:00
|
|
|
/*
|
|
|
|
* Take/release a lock when not the owner will release it.
|
|
|
|
*
|
|
|
|
* [ This API should be avoided as much as possible - the
|
|
|
|
* proper abstraction for this case is completions. ]
|
|
|
|
*/
|
|
|
|
extern void down_read_non_owner(struct rw_semaphore *sem);
|
|
|
|
extern void up_read_non_owner(struct rw_semaphore *sem);
|
2006-07-03 11:24:53 +04:00
|
|
|
#else
|
|
|
|
# define down_read_nested(sem, subclass) down_read(sem)
|
2013-01-15 23:12:37 +04:00
|
|
|
# define down_write_nest_lock(sem, nest_lock) down_write(sem)
|
2006-07-03 11:24:53 +04:00
|
|
|
# define down_write_nested(sem, subclass) down_write(sem)
|
2016-05-26 07:04:58 +03:00
|
|
|
# define down_write_killable_nested(sem, subclass) down_write_killable(sem)
|
2011-09-22 08:43:05 +04:00
|
|
|
# define down_read_non_owner(sem) down_read(sem)
|
|
|
|
# define up_read_non_owner(sem) up_read(sem)
|
2006-07-03 11:24:53 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#endif /* _LINUX_RWSEM_H */
|