From: Nick Piggin <npiggin@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>, Linux Arch <linux-arch@vger.kernel.org>
Subject: [patch 8/8] bit_spin_lock: use lock bitops
Date: Sun, 05 Aug 2007 06:29:32 +1000 [thread overview]
Message-ID: <20070804202932.13550.80385.sendpatchset@linux.local0.net> (raw)
In-Reply-To: <20070804202820.13550.67814.sendpatchset@linux.local0.net>
Convert bit_spin_lock to new locking bitops. Slub can use the non-atomic store
version to clear (Christoph?)
Signed-off-by: Nick Piggin <npiggin@suse.de>
---
include/linux/bit_spinlock.h | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
Index: linux-2.6/include/linux/bit_spinlock.h
===================================================================
--- linux-2.6.orig/include/linux/bit_spinlock.h
+++ linux-2.6/include/linux/bit_spinlock.h
@@ -18,7 +18,7 @@ static inline void bit_spin_lock(int bit
*/
preempt_disable();
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
- while (test_and_set_bit(bitnum, addr)) {
+ while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
while (test_bit(bitnum, addr)) {
preempt_enable();
cpu_relax();
@@ -36,7 +36,7 @@ static inline int bit_spin_trylock(int b
{
preempt_disable();
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
- if (test_and_set_bit(bitnum, addr)) {
+ if (unlikely(test_and_set_bit_lock(bitnum, addr))) {
preempt_enable();
return 0;
}
@@ -50,10 +50,28 @@ static inline int bit_spin_trylock(int b
*/
static inline void bit_spin_unlock(int bitnum, unsigned long *addr)
{
+#ifdef CONFIG_DEBUG_SPINLOCK
+ BUG_ON(!test_bit(bitnum, addr));
+#endif
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+ clear_bit_unlock(bitnum, addr);
+#endif
+ preempt_enable();
+ __release(bitlock);
+}
+
+/*
+ * bit-based spin_unlock()
+ * non-atomic version, which can be used eg. if the bit lock itself is
+ * protecting the rest of the flags in the word.
+ */
+static inline void __bit_spin_unlock(int bitnum, unsigned long *addr)
+{
+#ifdef CONFIG_DEBUG_SPINLOCK
BUG_ON(!test_bit(bitnum, addr));
- smp_mb__before_clear_bit();
- clear_bit(bitnum, addr);
+#endif
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+ __clear_bit_unlock(bitnum, addr);
#endif
preempt_enable();
__release(bitlock);
next prev parent reply other threads:[~2007-08-28 8:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-04 20:28 [patch 0/8] lock bitops and some bitops fixes Nick Piggin
2007-08-04 20:28 ` [patch 1/8] bitops: introduce lock ops Nick Piggin
2007-08-04 20:28 ` [patch 2/8] alpha: fix bitops Nick Piggin
2007-08-04 20:28 ` [patch 3/8] alpha: lock bitops Nick Piggin
2007-08-04 20:28 ` [patch 4/8] ia64: " Nick Piggin
2007-08-04 20:29 ` [patch 5/8] mips: fix bitops Nick Piggin
2007-08-04 20:29 ` [patch 6/8] mips: lock bitops Nick Piggin
2007-08-04 20:29 ` [patch 7/8] powerpc: " Nick Piggin
2007-08-04 20:29 ` Nick Piggin [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-08-28 8:14 [patch 0/8] lock bitops and some bitops fixes Nick Piggin
2007-08-28 8:16 ` [patch 8/8] bit_spin_lock: use lock bitops Nick Piggin
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=20070804202932.13550.80385.sendpatchset@linux.local0.net \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-arch@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).