From: Peter Zijlstra <peterz@infradead.org>
To: Kirill Tkhai <tkhai@yandex.ru>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
tglx@linutronix.de
Subject: Re: [PATCH] spin_unlock*_no_resched()
Date: Wed, 12 Jun 2013 14:15:32 +0200 [thread overview]
Message-ID: <20130612121532.GD3204@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1022041371038807@web30d.yandex.ru>
On Wed, Jun 12, 2013 at 04:06:47PM +0400, Kirill Tkhai wrote:
> There are many constructions like:
>
> spin_unlock_irq(lock);
> schedule();
>
> In case of preemptible kernel we check if task needs reschedule
> at the end of spin_unlock(). So if TIF_NEED_RESCHED is set
> we call schedule() twice and we have a little overhead here.
> Add primitives to avoid these situations.
>
> Signed-off-by: Kirill Tkhai <tkhai@yandex.ru>
> CC: Steven Rostedt <rostedt@goodmis.org>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> ---
> include/linux/spinlock.h | 27 +++++++++++++++++++++++++++
> include/linux/spinlock_api_smp.h | 37 +++++++++++++++++++++++++++++++++++++
> include/linux/spinlock_api_up.h | 13 +++++++++++++
> kernel/spinlock.c | 20 ++++++++++++++++++++
> 4 files changed, 97 insertions(+), 0 deletions(-)
> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 7d537ce..35caa32 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -221,13 +221,24 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
> #define raw_spin_lock_irq(lock) _raw_spin_lock_irq(lock)
> #define raw_spin_lock_bh(lock) _raw_spin_lock_bh(lock)
> #define raw_spin_unlock(lock) _raw_spin_unlock(lock)
> +#define raw_spin_unlock_no_resched(lock) \
> + _raw_spin_unlock_no_resched(lock)
> +
> #define raw_spin_unlock_irq(lock) _raw_spin_unlock_irq(lock)
> +#define raw_spin_unlock_irq_no_resched(lock) \
> + _raw_spin_unlock_irq_no_resched(lock)
>
> #define raw_spin_unlock_irqrestore(lock, flags) \
> do { \
> typecheck(unsigned long, flags); \
> _raw_spin_unlock_irqrestore(lock, flags); \
> } while (0)
> +#define raw_spin_unlock_irqrestore_no_resched(lock, flags) \
> + do { \
> + typecheck(unsigned long, flags); \
> + _raw_spin_unlock_irqrestore_no_resched(lock, flags); \
> + } while (0)
So I absolutely hate this API because people can (and invariably will)
abuse it; much like they did/do preempt_enable_no_resched().
IIRC Thomas even maps preempt_enable_no_resched() to preempt_enable() in
-rt to make sure we don't miss preemption points due to stupidity.
He converted the 'few' sane sites to use schedule_preempt_disabled(). In
that vein, does it make sense to introduce schedule_spin_locked()?
Also, your patch 'fails' to make use of the new API.
next prev parent reply other threads:[~2013-06-12 12:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-12 12:06 [PATCH] spin_unlock*_no_resched() Kirill Tkhai
2013-06-12 12:15 ` Peter Zijlstra [this message]
2013-06-12 13:07 ` Steven Rostedt
2013-06-12 23:06 ` Kirill Tkhai
2013-06-13 0:07 ` Kirill Tkhai
2013-06-18 10:05 ` Peter Zijlstra
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=20130612121532.GD3204@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tkhai@yandex.ru \
/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