From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
tglx@linutronix.de, Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
linux-arm-kernel@lists.infradead.org,
Mike Galbraith <efault@gmx.de>
Subject: [PATCH RT] locallock: add local_lock_bh()
Date: Fri, 13 Jul 2018 19:50:49 +0200 [thread overview]
Message-ID: <20180713175049.nx2xg4no4zbfcnfl@linutronix.de> (raw)
In-Reply-To: <20180713174937.5ddaqpylalcmc3jq@linutronix.de>
For the ARM64 simd locking it would be easier to have local_lock_bh()
which grabs a local_lock with BH disabled and turns into a
local_bh_disable() on !RT.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
obviously required by the previous one…
include/linux/locallock.h | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/include/linux/locallock.h b/include/linux/locallock.h
index 921eab83cd34..15aa0dea2bfb 100644
--- a/include/linux/locallock.h
+++ b/include/linux/locallock.h
@@ -47,9 +47,23 @@ static inline void __local_lock(struct local_irq_lock *lv)
lv->nestcnt++;
}
+static inline void __local_lock_bh(struct local_irq_lock *lv)
+{
+ if (lv->owner != current) {
+ spin_lock_bh(&lv->lock);
+ LL_WARN(lv->owner);
+ LL_WARN(lv->nestcnt);
+ lv->owner = current;
+ }
+ lv->nestcnt++;
+}
+
#define local_lock(lvar) \
do { __local_lock(&get_local_var(lvar)); } while (0)
+#define local_lock_bh(lvar) \
+ do { __local_lock_bh(&get_local_var(lvar)); } while (0)
+
#define local_lock_on(lvar, cpu) \
do { __local_lock(&per_cpu(lvar, cpu)); } while (0)
@@ -88,12 +102,29 @@ static inline void __local_unlock(struct local_irq_lock *lv)
spin_unlock(&lv->lock);
}
+static inline void __local_unlock_bh(struct local_irq_lock *lv)
+{
+ LL_WARN(lv->nestcnt == 0);
+ LL_WARN(lv->owner != current);
+ if (--lv->nestcnt)
+ return;
+
+ lv->owner = NULL;
+ spin_unlock_bh(&lv->lock);
+}
+
#define local_unlock(lvar) \
do { \
__local_unlock(this_cpu_ptr(&lvar)); \
put_local_var(lvar); \
} while (0)
+#define local_unlock_bh(lvar) \
+ do { \
+ __local_unlock_bh(this_cpu_ptr(&lvar)); \
+ put_local_var(lvar); \
+ } while (0)
+
#define local_unlock_on(lvar, cpu) \
do { __local_unlock(&per_cpu(lvar, cpu)); } while (0)
@@ -253,6 +284,8 @@ static inline void local_irq_lock_init(int lvar) { }
#define local_lock(lvar) preempt_disable()
#define local_unlock(lvar) preempt_enable()
+#define local_lock_bh(lvar) local_bh_disable()
+#define local_unlock_bh(lvar) local_bh_enable()
#define local_lock_irq(lvar) local_irq_disable()
#define local_lock_irq_on(lvar, cpu) local_irq_disable()
#define local_unlock_irq(lvar) local_irq_enable()
--
2.18.0
next prev parent reply other threads:[~2018-07-13 17:50 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-17 12:40 [PATCH RT] arm64: fpsimd: use a local_lock() in addition to local_bh_disable() Sebastian Andrzej Siewior
2018-05-17 18:19 ` Dave Martin
2018-05-18 12:46 ` Dave Martin
2018-05-23 14:34 ` Sebastian Andrzej Siewior
2018-05-23 14:31 ` Sebastian Andrzej Siewior
2018-05-23 14:55 ` Dave Martin
2018-05-22 17:10 ` Steven Rostedt
2018-05-22 17:21 ` Sebastian Andrzej Siewior
2018-05-22 17:24 ` Steven Rostedt
2018-05-22 17:33 ` Sebastian Andrzej Siewior
2018-07-11 13:25 ` Steven Rostedt
2018-07-11 13:31 ` Sebastian Andrzej Siewior
2018-07-11 13:33 ` Steven Rostedt
2018-07-13 17:49 ` [PATCH RT v2] " Sebastian Andrzej Siewior
2018-07-13 17:50 ` Sebastian Andrzej Siewior [this message]
2018-07-13 22:03 ` Mike Galbraith
2018-07-15 7:22 ` Mike Galbraith
2018-07-18 10:30 ` Mike Galbraith
2018-07-18 9:27 ` Sebastian Andrzej Siewior
2018-07-18 10:28 ` Mike Galbraith
2018-07-18 10:36 ` Sebastian Andrzej Siewior
2018-07-16 15:17 ` Dave Martin
2018-07-18 9:12 ` Sebastian Andrzej Siewior
2018-07-18 9:24 ` Sebastian Andrzej Siewior
2018-07-24 14:45 ` Dave Martin
2018-07-24 15:15 ` Ard Biesheuvel
2018-07-24 13:46 ` Steven Rostedt
2018-07-24 13:57 ` Sebastian Andrzej Siewior
2018-07-26 15:06 ` [PATCH RT v3] arm64: fpsimd: use preemp_disable " Sebastian Andrzej Siewior
2018-07-27 3:17 ` Mike Galbraith
2018-07-27 7:56 ` Sebastian Andrzej Siewior
2018-07-27 15:35 ` Dave Martin
2018-07-27 16:26 ` Sebastian Andrzej Siewior
2018-07-11 17:07 ` [PATCH RT] arm64: fpsimd: use a local_lock() " Mike Galbraith
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=20180713175049.nx2xg4no4zbfcnfl@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=catalin.marinas@arm.com \
--cc=efault@gmx.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).