diff options
author | Alexei Starovoitov <ast@kernel.org> | 2025-09-08 18:00:02 -0700 |
---|---|---|
committer | Vlastimil Babka <vbabka@suse.cz> | 2025-09-29 09:42:35 +0200 |
commit | 4957089a23f41f31f8e7e22802a8ef9f5789c191 (patch) | |
tree | 9531b4ed88e7710247c3f494720298ecfd3b1d2a /include/linux/rtmutex.h | |
parent | 4ec1a08d20315d2d2a6f942ea563e5dadd988e98 (diff) |
locking/local_lock: Introduce local_lock_is_locked().
Introduce local_lock_is_locked() that returns true when
given local_lock is locked by current cpu (in !PREEMPT_RT) or
by current task (in PREEMPT_RT).
The goal is to detect a deadlock by the caller.
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'include/linux/rtmutex.h')
-rw-r--r-- | include/linux/rtmutex.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index fa9f1021541e..ede4c6bf6f22 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -44,6 +44,16 @@ static inline bool rt_mutex_base_is_locked(struct rt_mutex_base *lock) return READ_ONCE(lock->owner) != NULL; } +#ifdef CONFIG_RT_MUTEXES +#define RT_MUTEX_HAS_WAITERS 1UL + +static inline struct task_struct *rt_mutex_owner(struct rt_mutex_base *lock) +{ + unsigned long owner = (unsigned long) READ_ONCE(lock->owner); + + return (struct task_struct *) (owner & ~RT_MUTEX_HAS_WAITERS); +} +#endif extern void rt_mutex_base_init(struct rt_mutex_base *rtb); /** |