mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Cc: Horst Hartmann <horsth@linux.vnet.ibm.com>,
	Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [Patch/RFC 0/4] Allow inlined spinlocks (again)
Date: Mon, 10 Aug 2009 10:13:24 +0200	[thread overview]
Message-ID: <20090810081324.GA30276@osiris.boeblingen.de.ibm.com> (raw)

This patch set allows to have inlined spinlocks (again).

The rationale behind this is that function calls on at least s390 are
expensive.
If one considers that server kernels are usually compiled with
!CONFIG_PREEMPT a simple spin_lock is just a compare and swap loop.
The extra overhead for a function call is significant.
With inlined spinlocks overall cpu usage gets reduced by 1%-5% on s390.
These numbers were taken with some network benchmarks. However I expect
any workload that calls frequently into the kernel and which grabs a few
spinlocks to perform better.

Please note: I'm aware that this implementation is a bit ;) ugly and
might also contain bugs. But the performance improvements show that its
worth to do something in this area.

The actual implemtation is quite simple: move the spinlock C code to
a header file and add some wrappers. Configuration dependent this
file gets included into a C file and normal spinlock functions like
we them currently will generated. Otherwise the inline variants
will be generated as we had them before the out of line code was
introduced:

A standard spinlock function like this

void __lockfunc _spin_lock(spinlock_t *lock)
{
...
}
EXPORT_SYMBOL(_spin_lock);

gets converted to

LOCKFUNC void _spin_lock(spinlock_t *lock)
{
...
}
SPIN_EXPORT_SYMBOL(_spin_lock);

where LOCKFUNC and SPIN_EXPORT_SYMBOL get expanded dependent
on CONFIG_SPINLOCK_INLINE:

#ifdef CONFIG_SPINLOCK_INLINE

#define LOCKFUNC                 static inline
#define SPIN_EXPORT_SYMBOL(func)

#else /* CONFIG_SPINLOCK_INLINE */

#define LOCKFUNC                 __lockfunc
#define SPIN_EXPORT_SYMBOL(func) EXPORT_SYMBOL(func)

#endif /* CONFIG_SPINLOCK_INLINE */

             reply	other threads:[~2009-08-10  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10  8:13 Heiko Carstens [this message]
2009-08-10  8:14 ` [Patch/RFC 1/4] spinlock: move code to header file Heiko Carstens
2009-08-10  8:15 ` [Patch/RFC 2/4] spinlock: move include statements Heiko Carstens
2009-08-10  8:15 ` [Patch/RFC 3/4] spinlock: allow inlined spinlocks Heiko Carstens
2009-08-10  8:16 ` [Patch/RFC 4/4] spinlock: allow inline spinlocks on s390 Heiko Carstens

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=20090810081324.GA30276@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=horsth@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=schwidefsky@de.ibm.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

all inboxes | Powered by JetHome®