Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1737022 > unrolled thread

[PATCH RT] rt/locking: allow recursive local_trylock()

Started bySebastian Andrzej Siewior <bigeasy@linutronix.de>
First post2017-09-21 21:20 +0200
Last post2017-09-21 21:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH RT] rt/locking: allow recursive local_trylock() Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-09-21 21:20 +0200

#1737022 — [PATCH RT] rt/locking: allow recursive local_trylock()

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-09-21 21:20 +0200
Subject[PATCH RT] rt/locking: allow recursive local_trylock()
Message-ID<usfaV-4XA-9@gated-at.bofh.it>
required for networking patch which does recursive try-lock.
While at it, add the !RT version of it because it did not yet exist.

Cc: rt-stable@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/locallock.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/locallock.h b/include/linux/locallock.h
index eeb1a66df402..d658c2552601 100644
--- a/include/linux/locallock.h
+++ b/include/linux/locallock.h
@@ -61,6 +61,9 @@ static inline int __local_trylock(struct local_irq_lock *lv)
 		lv->owner = current;
 		lv->nestcnt = 1;
 		return 1;
+	} else if (lv->owner == current) {
+		lv->nestcnt++;
+		return 1;
 	}
 	return 0;
 }
@@ -234,6 +237,12 @@ static inline int __local_unlock_irqrestore(struct local_irq_lock *lv,
 
 static inline void local_irq_lock_init(int lvar) { }
 
+#define local_trylock(lvar)					\
+	({							\
+		preempt_disable();				\
+		1;						\
+	})
+
 #define local_lock(lvar)			preempt_disable()
 #define local_unlock(lvar)			preempt_enable()
 #define local_lock_irq(lvar)			local_irq_disable()
-- 
2.14.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web