public inbox for linux-rt-devel@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] rtmutex: Introduce __cleanup() based infrastructure
@ 2026-02-02 17:04 Thomas Böhler
  2026-02-02 17:58 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Böhler @ 2026-02-02 17:04 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt
  Cc: linux-kernel, linux-rt-devel, Thomas Böhler

Commit 54da6a092431 ("locking: Introduce __cleanup() based
infrastructure") introduced lock guards for mutexes in
include/linux/mutex.h, but, presumably as PREEMPT_RT wasn't merged at
the time, the guard for rt_mutex was never created. Do this now so this
infrastructure exists for rt_mutex as well.

Signed-off-by: Thomas Böhler <witcher@wiredspace.de>
---
 include/linux/rtmutex.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index ede4c6bf6f22..3c766eba2c7d 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -17,6 +17,7 @@
 #include <linux/linkage.h>
 #include <linux/rbtree_types.h>
 #include <linux/spinlock_types_raw.h>
+#include <linux/cleanup.h>
 
 extern int max_lock_depth;
 
@@ -129,4 +130,8 @@ extern int rt_mutex_trylock(struct rt_mutex *lock);
 
 extern void rt_mutex_unlock(struct rt_mutex *lock);
 
+DEFINE_GUARD(rt_mutex, struct rt_mutex *, rt_mutex_lock(_T), rt_mutex_unlock(_T))
+DEFINE_GUARD_COND(rt_mutex, _try, rt_mutex_trylock(_T))
+DEFINE_GUARD_COND(rt_mutex, _intr, rt_mutex_lock_interruptible(_T), _RET == 0)
+
 #endif

---
base-commit: 18f7fcd5e69a04df57b563360b88be72471d6b62
change-id: 20260202-rt_mutex-guard-bfa1518b4f13

Best regards,
-- 
Thomas Böhler <witcher@wiredspace.de>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-03 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 17:04 [PATCH] rtmutex: Introduce __cleanup() based infrastructure Thomas Böhler
2026-02-02 17:58 ` Sebastian Andrzej Siewior
2026-02-02 18:59   ` Thomas Böhler
2026-02-03 11:33     ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox