From: Nicholas Mc Guire <der.herr@hofr.at>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-rt-users@vger.kernel.org,
Sami Pietikainen <Sami.Pietikainen@wapice.com>,
Jouko Haapaluoma <jouko.haapaluoma@wapice.com>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH RT] use local spin_locks in local_lock
Date: Fri, 17 Jan 2014 20:41:58 +0100 [thread overview]
Message-ID: <20140117194158.GB20157@opentech.at> (raw)
In-Reply-To: <20140117113218.7392363d@gandalf.local.home>
Drop recursive call to migrate_disabel/enable for local_*lock* api
reported by Steven Rostedt.
local_lock will call migrate_disable via get_local_var - call tree is
get_locked_var
`-> local_lock(lvar)
`-> __local_lock(&get_local_var(lvar));
`--> # define get_local_var(var) (*({
migrate_disable();
&__get_cpu_var(var); })) \
thus there should be no need to call migrate_disable/enable recursively in
spin_try/lock/unlock. This patch addes a spin_trylock_local and replaces
the migration disabling calls by the local calls.
This patch is incomplete as it does not yet cover the _irq/_irqsave variants
by local locks. This patch requires the API cleanup in kernel/softirq.c or
it would break softirq_lock/unlock with respect to migration.
on top of -rt9 with timers-do-not-raise-softirq-unconditionally.patch removed
and API-cleanup-use-local_lock-not-__local_lock-for-soft.patch applied.
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
include/linux/locallock.h | 8 ++++----
include/linux/spinlock_rt.h | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/locallock.h b/include/linux/locallock.h
index e7bd8be..32c684b 100644
--- a/include/linux/locallock.h
+++ b/include/linux/locallock.h
@@ -39,7 +39,7 @@ struct local_irq_lock {
static inline void __local_lock(struct local_irq_lock *lv)
{
if (lv->owner != current) {
- spin_lock(&lv->lock);
+ spin_lock_local(&lv->lock);
LL_WARN(lv->owner);
LL_WARN(lv->nestcnt);
lv->owner = current;
@@ -52,7 +52,7 @@ static inline void __local_lock(struct local_irq_lock *lv)
static inline int __local_trylock(struct local_irq_lock *lv)
{
- if (lv->owner != current && spin_trylock(&lv->lock)) {
+ if (lv->owner != current && spin_trylock_local(&lv->lock)) {
LL_WARN(lv->owner);
LL_WARN(lv->nestcnt);
lv->owner = current;
@@ -79,7 +79,7 @@ static inline void __local_unlock(struct local_irq_lock *lv)
return;
lv->owner = NULL;
- spin_unlock(&lv->lock);
+ spin_unlock_local(&lv->lock);
}
#define local_unlock(lvar) \
@@ -211,7 +211,7 @@ static inline int __local_unlock_irqrestore(struct local_irq_lock *lv,
&__get_cpu_var(var); \
}))
-#define put_locked_var(lvar, var) local_unlock(lvar)
+#define put_locked_var(lvar, var) local_unlock(lvar);
#define local_lock_cpu(lvar) \
({ \
diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h
index b3c504b..4f91114 100644
--- a/include/linux/spinlock_rt.h
+++ b/include/linux/spinlock_rt.h
@@ -37,6 +37,7 @@ extern void __lockfunc __rt_spin_lock(struct rt_mutex *lock);
extern void __lockfunc __rt_spin_unlock(struct rt_mutex *lock);
#define spin_lock_local(lock) rt_spin_lock(lock)
+#define spin_trylock_local(lock) rt_spin_trylock(lock)
#define spin_unlock_local(lock) rt_spin_unlock(lock)
#define spin_lock(lock) \
--
1.7.2.5
next prev parent reply other threads:[~2014-01-17 19:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-29 17:11 [PATCH RT] add missing local serialization in ip_output.c Nicholas Mc Guire
2013-12-31 7:36 ` Jouko Haapaluoma
2014-01-08 7:11 ` Sami Pietikäinen
2014-01-17 14:47 ` Sebastian Andrzej Siewior
2014-01-17 14:59 ` Nicholas Mc Guire
2014-01-17 15:13 ` Sebastian Andrzej Siewior
2014-01-17 15:33 ` Nicholas Mc Guire
2014-01-17 16:32 ` Steven Rostedt
2014-01-17 19:40 ` Nicholas Mc Guire
2014-01-17 19:41 ` Nicholas Mc Guire [this message]
2014-01-31 20:24 ` [PATCH RT] use local spin_locks in local_lock Sebastian Andrzej Siewior
2014-01-17 19:44 ` [PATCH] API cleanup - use local_lock not __local_lock for soft Nicholas Mc Guire
2014-01-31 20:28 ` Sebastian Andrzej Siewior
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=20140117194158.GB20157@opentech.at \
--to=der.herr@hofr.at \
--cc=Sami.Pietikainen@wapice.com \
--cc=bigeasy@linutronix.de \
--cc=jouko.haapaluoma@wapice.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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).