From: tip-bot for Jason Low <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, konrad.wilk@oracle.com,
torvalds@linux-foundation.org, peterz@infradead.org,
jason.low2@hp.com, clm@fb.com, riel@redhat.com,
rostedt@goodmis.org, akpm@linux-foundation.org,
tglx@linutronix.de, david@fromorbit.com, davidlohr@hp.com,
scott.norton@hp.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
waiman.long@hp.com, tim.c.chen@linux.intel.com,
paulmck@linux.vnet.ibm.com, jbacik@fusionio.com, aswin@hp.com
Subject: [tip:locking/urgent] locking/rwsem: Reduce the size of struct rw_semaphore
Date: Wed, 16 Jul 2014 12:24:18 -0700 [thread overview]
Message-ID: <tip-ce069fc920e5734558b3d9cbef1ab06cf01ee793@git.kernel.org> (raw)
In-Reply-To: <1405358872-3732-6-git-send-email-jason.low2@hp.com>
Commit-ID: ce069fc920e5734558b3d9cbef1ab06cf01ee793
Gitweb: http://git.kernel.org/tip/ce069fc920e5734558b3d9cbef1ab06cf01ee793
Author: Jason Low <jason.low2@hp.com>
AuthorDate: Mon, 14 Jul 2014 10:27:52 -0700
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 16 Jul 2014 14:57:03 +0200
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>
---
include/linux/rwsem.h | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 25cd9aa..716807f 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -24,15 +24,15 @@ struct rw_semaphore;
/* All arch specific implementations share the same struct */
struct rw_semaphore {
long count;
- raw_spinlock_t wait_lock;
struct list_head wait_list;
+ raw_spinlock_t wait_lock;
#ifdef CONFIG_SMP
+ struct optimistic_spin_queue osq; /* spinner MCS lock */
/*
* Write owner. Used as a speculative check to see
* if the owner is running on the cpu.
*/
struct task_struct *owner;
- struct optimistic_spin_queue osq; /* spinner MCS lock */
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
@@ -64,21 +64,18 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
#endif
#if defined(CONFIG_SMP) && !defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
-#define __RWSEM_INITIALIZER(name) \
- { RWSEM_UNLOCKED_VALUE, \
- __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \
- LIST_HEAD_INIT((name).wait_list), \
- NULL, /* owner */ \
- OSQ_LOCK_UNLOCKED /* osq */ \
- __RWSEM_DEP_MAP_INIT(name) }
+#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
#else
-#define __RWSEM_INITIALIZER(name) \
- { RWSEM_UNLOCKED_VALUE, \
- __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \
- LIST_HEAD_INIT((name).wait_list) \
- __RWSEM_DEP_MAP_INIT(name) }
+#define __RWSEM_OPT_INIT(lockname)
#endif
+#define __RWSEM_INITIALIZER(name) \
+ { .count = RWSEM_UNLOCKED_VALUE, \
+ .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) }
+
#define DECLARE_RWSEM(name) \
struct rw_semaphore name = __RWSEM_INITIALIZER(name)
prev parent reply other threads:[~2014-07-16 19:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 17:27 [PATCH v2 0/5] MCS spinlocks: Cancellable MCS spinlock rework Jason Low
2014-07-14 17:27 ` [PATCH v2 1/5] MCS spinlocks: Rename optimistic_spin_queue to optimistic_spin_node Jason Low
2014-07-16 19:20 ` [tip:locking/urgent] locking/spinlocks/mcs: Rename optimistic_spin_queue() to optimistic_spin_node() tip-bot for Jason Low
2014-07-14 17:27 ` [PATCH v2 2/5] MCS spinlocks: Convert osq lock to atomic_t to reduce overhead Jason Low
2014-07-16 19:20 ` [tip:locking/urgent] locking/spinlocks/mcs: " tip-bot for Jason Low
2014-07-14 17:27 ` [PATCH v2 3/5] MCS spinlocks: Introduce and use init macro and function for osq locks Jason Low
2014-07-16 19:21 ` [tip:locking/urgent] locking/spinlocks/mcs: " tip-bot for Jason Low
2014-07-14 17:27 ` [PATCH v2 4/5] MCS spinlocks: Micro-optimize osq_unlock() Jason Low
2014-07-16 19:21 ` [tip:locking/urgent] locking/spinlocks/mcs: " tip-bot for Jason Low
2014-07-14 17:27 ` [PATCH v2 5/5] rwsem: Reduce the size of struct rw_semaphore Jason Low
2014-07-16 19:24 ` tip-bot for Jason Low [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-ce069fc920e5734558b3d9cbef1ab06cf01ee793@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=aswin@hp.com \
--cc=clm@fb.com \
--cc=david@fromorbit.com \
--cc=davidlohr@hp.com \
--cc=hpa@zytor.com \
--cc=jason.low2@hp.com \
--cc=jbacik@fusionio.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=rostedt@goodmis.org \
--cc=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=waiman.long@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox