From: Mike Galbraith <umgwanakikbuti@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [rfc patch] locking: Cleanup local locks
Date: Tue, 14 Jun 2016 10:56:02 +0200 [thread overview]
Message-ID: <1465894562.2882.8.camel@gmail.com> (raw)
1. Remove unneeded local_irq_lock.flags.
2. Make local_lock_irq() use spin_lock/unlock_irq() for PREEMPT_RTB
3. Make local_lock_irqsave/on() disable irqs for PREEMPT_RTB without
mucking about with remote cpu ->flags for local_lock_irqsave_on().
4. Line up backslashes for no particular reason.
Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
---
include/linux/locallock.h | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
--- a/include/linux/locallock.h
+++ b/include/linux/locallock.h
@@ -19,7 +19,6 @@ struct local_irq_lock {
spinlock_t lock;
struct task_struct *owner;
int nestcnt;
- unsigned long flags;
};
#define DEFINE_LOCAL_IRQ_LOCK(lvar) \
@@ -46,10 +45,14 @@ struct local_irq_lock {
# define spin_lock_local(lock) rt_spin_lock__no_mg(lock)
# define spin_trylock_local(lock) rt_spin_trylock__no_mg(lock)
# define spin_unlock_local(lock) rt_spin_unlock__no_mg(lock)
+# define spin_lock_irq_local(lock) rt_spin_lock__no_mg(lock)
+# define spin_unlock_irq_local(lock) rt_spin_unlock__no_mg(lock)
#else
# define spin_lock_local(lock) spin_lock(lock)
# define spin_trylock_local(lock) spin_trylock(lock)
# define spin_unlock_local(lock) spin_unlock(lock)
+# define spin_lock_irq_local(lock) spin_lock_irq(lock)
+# define spin_unlock_irq_local(lock) spin_unlock_irq(lock)
#endif
static inline void __local_lock(struct local_irq_lock *lv)
@@ -63,10 +66,10 @@ static inline void __local_lock(struct l
lv->nestcnt++;
}
-#define local_lock(lvar) \
+#define local_lock(lvar) \
do { __local_lock(&get_local_var(lvar)); } while (0)
-#define local_lock_on(lvar, cpu) \
+#define local_lock_on(lvar, cpu) \
do { __local_lock(&per_cpu(lvar, cpu)); } while (0)
static inline int __local_trylock(struct local_irq_lock *lv)
@@ -101,18 +104,18 @@ static inline void __local_unlock(struct
spin_unlock_local(&lv->lock);
}
-#define local_unlock(lvar) \
- do { \
- __local_unlock(this_cpu_ptr(&lvar)); \
- put_local_var(lvar); \
+#define local_unlock(lvar) \
+ do { \
+ __local_unlock(this_cpu_ptr(&lvar)); \
+ put_local_var(lvar); \
} while (0)
-#define local_unlock_on(lvar, cpu) \
+#define local_unlock_on(lvar, cpu) \
do { __local_unlock(&per_cpu(lvar, cpu)); } while (0)
static inline void __local_lock_irq(struct local_irq_lock *lv)
{
- spin_lock_irqsave(&lv->lock, lv->flags);
+ spin_lock_irq_local(&lv->lock);
LL_WARN(lv->owner);
LL_WARN(lv->nestcnt);
lv->owner = current;
@@ -131,7 +134,7 @@ static inline void __local_unlock_irq(st
LL_WARN(lv->owner != current);
lv->owner = NULL;
lv->nestcnt = 0;
- spin_unlock_irq(&lv->lock);
+ spin_unlock_irq_local(&lv->lock);
}
#define local_unlock_irq(lvar) \
@@ -148,7 +151,7 @@ static inline void __local_unlock_irq(st
static inline int __local_lock_irqsave(struct local_irq_lock *lv)
{
if (lv->owner != current) {
- __local_lock_irq(lv);
+ __local_lock(lv);
return 0;
} else {
lv->nestcnt++;
@@ -156,21 +159,20 @@ static inline int __local_lock_irqsave(s
}
}
-#define local_lock_irqsave(lvar, _flags) \
+#define local_lock_irqsave(lvar, flags) \
do { \
+ local_irq_save_nort(flags); \
if (__local_lock_irqsave(&get_local_var(lvar))) \
put_local_var(lvar); \
- _flags = __this_cpu_read(lvar.flags); \
} while (0)
-#define local_lock_irqsave_on(lvar, _flags, cpu) \
+#define local_lock_irqsave_on(lvar, flags, cpu) \
do { \
+ local_irq_save_nort(flags); \
__local_lock_irqsave(&per_cpu(lvar, cpu)); \
- _flags = per_cpu(lvar, cpu).flags; \
} while (0)
-static inline int __local_unlock_irqrestore(struct local_irq_lock *lv,
- unsigned long flags)
+static inline int __local_unlock_irqrestore(struct local_irq_lock *lv)
{
LL_WARN(!lv->nestcnt);
LL_WARN(lv->owner != current);
@@ -178,19 +180,21 @@ static inline int __local_unlock_irqrest
return 0;
lv->owner = NULL;
- spin_unlock_irqrestore(&lv->lock, lv->flags);
+ spin_unlock_local(&lv->lock);
return 1;
}
#define local_unlock_irqrestore(lvar, flags) \
do { \
- if (__local_unlock_irqrestore(this_cpu_ptr(&lvar), flags)) \
+ if (__local_unlock_irqrestore(this_cpu_ptr(&lvar))) \
put_local_var(lvar); \
+ local_irq_restore_nort(flags); \
} while (0)
#define local_unlock_irqrestore_on(lvar, flags, cpu) \
do { \
- __local_unlock_irqrestore(&per_cpu(lvar, cpu), flags); \
+ __local_unlock_irqrestore(&per_cpu(lvar, cpu)); \
+ local_irq_restore_nort(flags); \
} while (0)
#define local_spin_trylock_irq(lvar, lock) \
reply other threads:[~2016-06-14 8:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1465894562.2882.8.camel@gmail.com \
--to=umgwanakikbuti@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=linux-rt-users@vger.kernel.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).