aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Low <jason.low2@hp.com>2014-07-14 13:27:52 -0400
committerIngo Molnar <mingo@kernel.org>2014-07-16 08:57:03 -0400
commitce069fc920e5734558b3d9cbef1ab06cf01ee793 (patch)
tree670f20c5f3c1f7560e73dc9aa07d6bf919f1ad3f
parent13b9a962a2594ee880c5d50d7f70964da1d4fe5a (diff)
locking/rwsem: Reduce the size of struct rw_semaphore
Recent optimistic spinning additions to rwsem provide significant performance benefits on many workloads on large machines. The cost of it was increasing the size of the rwsem structure by up to 128 bits. However, now that the previous patches in this series bring the overhead of struct optimistic_spin_queue to 32 bits, this patch reorders some fields in struct rw_semaphore such that we can reduce the overhead of the rwsem structure by 64 bits (on 64 bit systems). The extra overhead required for rwsem optimistic spinning would now be up to 8 additional bytes instead of up to 16 bytes. Additionally, the size of rwsem would now be more in line with mutexes. Signed-off-by: Jason Low <jason.low2@hp.com> Signed-off-by: Peter 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-6-git-send-email-jason.low2@hp.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--include/linux/rwsem.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 25cd9aa2f3d7..716807f0eb2d 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -24,15 +24,15 @@ struct rw_semaphore;
24/* All arch specific implementations share the same struct */ 24/* All arch specific implementations share the same struct */
25struct rw_semaphore { 25struct rw_semaphore {
26 long count; 26 long count;
27 raw_spinlock_t wait_lock;
28 struct list_head wait_list; 27 struct list_head wait_list;
28 raw_spinlock_t wait_lock;
29#ifdef CONFIG_SMP 29#ifdef CONFIG_SMP
30 struct optimistic_spin_queue osq; /* spinner MCS lock */
30 /* 31 /*
31 * Write owner. Used as a speculative check to see 32 * Write owner. Used as a speculative check to see
32 * if the owner is running on the cpu. 33 * if the owner is running on the cpu.
33 */ 34 */
34 struct task_struct *owner; 35 struct task_struct *owner;
35 struct optimistic_spin_queue osq; /* spinner MCS lock */
36#endif 36#endif
37#ifdef CONFIG_DEBUG_LOCK_ALLOC 37#ifdef CONFIG_DEBUG_LOCK_ALLOC
38 struct lockdep_map dep_map; 38 struct lockdep_map dep_map;
@@ -64,21 +64,18 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
64#endif 64#endif
65 65
66#if defined(CONFIG_SMP) && !defined(CONFIG_RWSEM_GENERIC_SPINLOCK) 66#if defined(CONFIG_SMP) && !defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
67#define __RWSEM_INITIALIZER(name) \ 67#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
68 { RWSEM_UNLOCKED_VALUE, \
69 __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \
70 LIST_HEAD_INIT((name).wait_list), \
71 NULL, /* owner */ \
72 OSQ_LOCK_UNLOCKED /* osq */ \
73 __RWSEM_DEP_MAP_INIT(name) }
74#else 68#else
75#define __RWSEM_INITIALIZER(name) \ 69#define __RWSEM_OPT_INIT(lockname)
76 { RWSEM_UNLOCKED_VALUE, \
77 __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \
78 LIST_HEAD_INIT((name).wait_list) \
79 __RWSEM_DEP_MAP_INIT(name) }
80#endif 70#endif
81 71
72#define __RWSEM_INITIALIZER(name) \
73 { .count = RWSEM_UNLOCKED_VALUE, \
74 .wait_list = LIST_HEAD_INIT((name).wait_list), \
75 .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
76 __RWSEM_OPT_INIT(name) \
77 __RWSEM_DEP_MAP_INIT(name) }
78
82#define DECLARE_RWSEM(name) \ 79#define DECLARE_RWSEM(name) \
83 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 80 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
84 81