From: "Thomas Böhler" <witcher@wiredspace.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
"Thomas Böhler" <witcher@wiredspace.de>
Subject: [PATCH] rtmutex: Introduce __cleanup() based infrastructure
Date: Mon, 02 Feb 2026 18:04:43 +0100 [thread overview]
Message-ID: <20260202-rt_mutex-guard-v1-1-1c078dbeee57@wiredspace.de> (raw)
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>
next reply other threads:[~2026-02-02 17:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 17:04 Thomas Böhler [this message]
2026-02-02 17:58 ` Sebastian Andrzej Siewior
2026-02-02 18:59 ` Thomas Böhler
2026-02-03 11:33 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260202-rt_mutex-guard-v1-1-1c078dbeee57@wiredspace.de \
--to=witcher@wiredspace.de \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®