linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Roman Zippel <zippel@linux-m68k.org>,
	linux-arch@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnd Bergmann <arnd@arndb.de>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Horst Hartmann <horsth@linux.vnet.ibm.com>,
	Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Subject: Re: [patch 0/8] Allow inlined spinlocks again V5
Date: Sat, 29 Aug 2009 15:59:07 +0200	[thread overview]
Message-ID: <20090829135906.GA11215@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20090829111642.GA17951@elte.hu>

On Sat, Aug 29, 2009 at 01:16:42PM +0200, Ingo Molnar wrote:
> * Heiko Carstens <heiko.carstens@de.ibm.com> wrote:
> > This patch set allows to have inlined spinlocks again.
> > 
> > V5: simplify ifdefs as pointed out by Linus. Fix architecture compile
> >     breakages caused by this change.
> > 
> > Linus, Ingo, do you still have objections?
> 
> Ok, this looks pretty clean.
> 
> Two small comments. One (small) worry is that the configuration 
> space of this construct:
> 
> +#define __spin_lock_is_small
> [...]
> 
> Is 2^28.
> 
> Could we perhaps shape this in a form that makes it 'formally' a 
> manually tuned inlining decision - where we already accept such kind 
> of per function decisions and know how to handle them?
> 
> I.e. rename it to something like:
> 
>   #define __always_inline__write_unlock_irqrestore
> 
> That way it fits into our existing forced-inlining attributes 
> (visually and name-space wise), which means the addition of 'inline' 
> or '__forced_inline', or the removal of such attributes.

Ok, I'll wait for more comments and post an updated version.

> The other comment i have: you dont seem to have preserved the 
> current auto-inlining of spin_lock() we did before, have you? 
> Without that this patchset causes a (small) performance regression 
> on every architectures but s390.

I assume you're talking of spin_unlock() and not spin_lock()?

It still gets inlined (spinlock.h):

/*
 * We inline the unlock functions in the nondebug case:
 */
#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
	!defined(CONFIG_SMP)
# define spin_unlock(lock)              _spin_unlock(lock)
[...]
#else
# define spin_unlock(lock) \
	do {__raw_spin_unlock(&(lock)->raw_lock); __release(lock); } while (0)
[...]

Or in other words, specifying __spin_lock_is_small causes only that the
out-of-line variant doesn't get generated anymore.
It gets inlined regardless (if config options allow).

Now this could be simplified/cleanup by doing something like this:

/*
 * We inline the unlock functions in the nondebug case:
 */
#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
	!defined(CONFIG_SMP)
# define spin_unlock(lock)              _spin_unlock(lock)
[...]
#else
# define spin_unlock(lock) \
	do {__raw_spin_unlock(&(lock)->raw_lock); __release(lock); } while (0)
[...]

However it sucks a bit that we have two different ways to force inlining.
So we could and probably should simplify this. The patch below (untested)
would do that:

---
 include/linux/spinlock.h         |   46 +++++----------------------------------
 include/linux/spinlock_api_smp.h |   12 ++++++++++
 2 files changed, 18 insertions(+), 40 deletions(-)

Index: linux-2.6/include/linux/spinlock.h
===================================================================
--- linux-2.6.orig/include/linux/spinlock.h
+++ linux-2.6/include/linux/spinlock.h
@@ -259,50 +259,16 @@ static inline void smp_mb__after_lock(vo
 
 #define spin_lock_irq(lock)		_spin_lock_irq(lock)
 #define spin_lock_bh(lock)		_spin_lock_bh(lock)
-
 #define read_lock_irq(lock)		_read_lock_irq(lock)
 #define read_lock_bh(lock)		_read_lock_bh(lock)
-
 #define write_lock_irq(lock)		_write_lock_irq(lock)
 #define write_lock_bh(lock)		_write_lock_bh(lock)
-
-/*
- * We inline the unlock functions in the nondebug case:
- */
-#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
-	!defined(CONFIG_SMP)
-# define spin_unlock(lock)		_spin_unlock(lock)
-# define read_unlock(lock)		_read_unlock(lock)
-# define write_unlock(lock)		_write_unlock(lock)
-# define spin_unlock_irq(lock)		_spin_unlock_irq(lock)
-# define read_unlock_irq(lock)		_read_unlock_irq(lock)
-# define write_unlock_irq(lock)		_write_unlock_irq(lock)
-#else
-# define spin_unlock(lock) \
-    do {__raw_spin_unlock(&(lock)->raw_lock); __release(lock); } while (0)
-# define read_unlock(lock) \
-    do {__raw_read_unlock(&(lock)->raw_lock); __release(lock); } while (0)
-# define write_unlock(lock) \
-    do {__raw_write_unlock(&(lock)->raw_lock); __release(lock); } while (0)
-# define spin_unlock_irq(lock)			\
-do {						\
-	__raw_spin_unlock(&(lock)->raw_lock);	\
-	__release(lock);			\
-	local_irq_enable();			\
-} while (0)
-# define read_unlock_irq(lock)			\
-do {						\
-	__raw_read_unlock(&(lock)->raw_lock);	\
-	__release(lock);			\
-	local_irq_enable();			\
-} while (0)
-# define write_unlock_irq(lock)			\
-do {						\
-	__raw_write_unlock(&(lock)->raw_lock);	\
-	__release(lock);			\
-	local_irq_enable();			\
-} while (0)
-#endif
+#define spin_unlock(lock)		_spin_unlock(lock)
+#define read_unlock(lock)		_read_unlock(lock)
+#define write_unlock(lock)		_write_unlock(lock)
+#define spin_unlock_irq(lock)		_spin_unlock_irq(lock)
+#define read_unlock_irq(lock)		_read_unlock_irq(lock)
+#define write_unlock_irq(lock)		_write_unlock_irq(lock)
 
 #define spin_unlock_irqrestore(lock, flags)		\
 	do {						\
Index: linux-2.6/include/linux/spinlock_api_smp.h
===================================================================
--- linux-2.6.orig/include/linux/spinlock_api_smp.h
+++ linux-2.6/include/linux/spinlock_api_smp.h
@@ -60,6 +60,18 @@ void __lockfunc _read_unlock_irqrestore(
 void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
 							__releases(lock);
 
+/*
+ * We inline the unlock functions in the nondebug case:
+ */
+#if !defined(CONFIG_DEBUG_SPINLOCK) && !defined(CONFIG_PREEMPT)
+#define __spin_unlock_is_small
+#define __read_unlock_is_small
+#define __write_unlock_is_small
+#define __spin_unlock_irq_is_small
+#define __read_unlock_irq_is_small
+#define __write_unlock_irq_is_small
+#endif
+
 #ifndef CONFIG_DEBUG_SPINLOCK
 #ifndef CONFIG_GENERIC_LOCKBREAK
 

  reply	other threads:[~2009-08-29 13:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-29 10:21 [patch 0/8] Allow inlined spinlocks again V5 Heiko Carstens
2009-08-29 10:21 ` Heiko Carstens
2009-08-29 10:21 ` [patch 1/8] powerpc: rename __spin_try_lock() and friends Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 2/8] sparc: " Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 22:27   ` David Miller
2009-08-29 10:21 ` [patch 3/8] m68k/asm-offsets: rename pt_regs offset defines Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 4/8] m68k/asm-offsets: rename signal defines Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 5/8] m68k: calculate thread_info offset with asm offset Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 6/8] spinlock: move spinlock function bodies to header file Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 7/8] spinlock: allow inlined spinlocks Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 10:21 ` [patch 8/8] spinlock: inline code for all locking variants on s390 Heiko Carstens
2009-08-29 10:21   ` Heiko Carstens
2009-08-29 11:16 ` [patch 0/8] Allow inlined spinlocks again V5 Ingo Molnar
2009-08-29 13:59   ` Heiko Carstens [this message]
2009-08-29 14:13     ` Ingo Molnar
2009-08-31  8:59       ` Heiko Carstens
2009-09-01 13:19         ` Ingo Molnar

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=20090829135906.GA11215@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=geert@linux-m68k.org \
    --cc=horsth@linux.vnet.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=paulus@samba.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=zippel@linux-m68k.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).