From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Rostedt Subject: [PATCH RT 11/13] rt/locking: allow recursive local_trylock() Date: Wed, 17 Jan 2018 10:14:15 -0500 Message-ID: <20180117151432.344452068@goodmis.org> References: <20180117151404.093229667@goodmis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Julia Cartwright , Daniel Wagner , tom.zanussi@linux.intel.com, Alex Shi , stable-rt@vger.kernel.org To: linux-kernel@vger.kernel.org, linux-rt-users Return-path: Content-Disposition: inline; filename=0011-rt-locking-allow-recursive-local_trylock.patch Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-rt-users.vger.kernel.org 3.18.91-rt98-rc1 stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior required for following networking patch which does recursive try-lock. While at it, add the !RT version of it because it did not yet exist. Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) --- include/linux/locallock.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/locallock.h b/include/linux/locallock.h index 015271ff8ec8..930ec941c2c0 100644 --- a/include/linux/locallock.h +++ b/include/linux/locallock.h @@ -77,6 +77,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; } @@ -250,6 +253,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.13.2