From: Jiri Kosina <jkosina@suse.cz>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: spinlocks -- why are releases inlined and acquires are not?
Date: Tue, 1 Apr 2008 02:40:37 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.64.0804010236110.5541@jikos.suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.64.0804010202390.5541@jikos.suse.cz>
On Tue, 1 Apr 2008, Jiri Kosina wrote:
> What is the reason for this asymetry? Shouldn't the acquiring functions
> be implemented in the very same way? Or at least, shouldn't all the
> __lockfunc functions be inlined?
i.e. is there any particular reason why we don't have something like the
patch below (implemented for all the lock variants of course, this is
just to demonstrate what I mean)?
spinlocks: inline spin_lock() in non-debug cases
inline spin_lock() in the non-debug case.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 576a5f7..30922ba 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -178,7 +178,12 @@ do { \
#define read_trylock(lock) __cond_lock(lock, _read_trylock(lock))
#define write_trylock(lock) __cond_lock(lock, _write_trylock(lock))
+#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
+ !defined(CONFIG_SMP)
#define spin_lock(lock) _spin_lock(lock)
+#else
+#define spin_lock(lock) \
+ do { __raw_spin_lock(&(lock)->raw_lock); __acquire(lock); } while (0)
#ifdef CONFIG_DEBUG_LOCK_ALLOC
# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass)
next prev parent reply other threads:[~2008-04-01 0:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-01 0:08 Jiri Kosina
2008-04-01 0:40 ` Jiri Kosina [this message]
2008-04-01 8:33 ` Ingo Molnar
2008-04-01 8:38 ` Jiri Kosina
2008-04-01 8:43 ` Ingo Molnar
2008-04-01 8:44 ` Jiri Kosina
2008-04-01 11:12 ` Andi Kleen
2008-04-01 12:40 ` Jiri Kosina
2008-04-01 13:30 ` Andi Kleen
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=Pine.LNX.4.64.0804010236110.5541@jikos.suse.cz \
--to=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
all inboxes | Powered by JetHome®