summaryrefslogtreecommitdiff
path: root/include/linux/local_lock_internal.h
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2025-09-08 18:00:02 -0700
committerVlastimil Babka <vbabka@suse.cz>2025-09-29 09:42:35 +0200
commit4957089a23f41f31f8e7e22802a8ef9f5789c191 (patch)
tree9531b4ed88e7710247c3f494720298ecfd3b1d2a /include/linux/local_lock_internal.h
parent4ec1a08d20315d2d2a6f942ea563e5dadd988e98 (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/local_lock_internal.h')
-rw-r--r--include/linux/local_lock_internal.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
index 949de37700db..a4dc479157b5 100644
--- a/include/linux/local_lock_internal.h
+++ b/include/linux/local_lock_internal.h
@@ -165,6 +165,9 @@ do { \
!!tl; \
})
+/* preemption or migration must be disabled before calling __local_lock_is_locked */
+#define __local_lock_is_locked(lock) READ_ONCE(this_cpu_ptr(lock)->acquired)
+
#define __local_lock_release(lock) \
do { \
local_trylock_t *tl; \
@@ -285,4 +288,8 @@ do { \
__local_trylock(lock); \
})
+/* migration must be disabled before calling __local_lock_is_locked */
+#define __local_lock_is_locked(__lock) \
+ (rt_mutex_owner(&this_cpu_ptr(__lock)->lock) == current)
+
#endif /* CONFIG_PREEMPT_RT */