linux/debian/patches-rt/0136-rtmutex-Add-rtmutex_lo...

57 lines
1.9 KiB
Diff
Raw Normal View History

From: Thomas Gleixner <tglx@linutronix.de>
2019-04-08 23:49:20 +00:00
Date: Thu, 9 Jun 2011 11:43:52 +0200
2019-11-25 00:04:39 +00:00
Subject: [PATCH 136/290] rtmutex: Add rtmutex_lock_killable()
Origin: https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=d10ccdda6815a479f62a22fdbe86b733a8f0fe79
Add "killable" type to rtmutex. We need this since rtmutex are used as
"normal" mutexes which do use this type.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
2019-04-08 23:49:20 +00:00
include/linux/rtmutex.h | 1 +
kernel/locking/rtmutex.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
2019-04-08 23:49:20 +00:00
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 6fd615a0eea9..81ece6a8291a 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
2019-04-08 23:49:20 +00:00
@@ -115,6 +115,7 @@ extern void rt_mutex_lock(struct rt_mutex *lock);
#endif
extern int rt_mutex_lock_interruptible(struct rt_mutex *lock);
+extern int rt_mutex_lock_killable(struct rt_mutex *lock);
extern int rt_mutex_timed_lock(struct rt_mutex *lock,
struct hrtimer_sleeper *timeout);
2019-04-08 23:49:20 +00:00
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 1c3f56d3d9b6..a4b2af7718f8 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
2019-04-08 23:49:20 +00:00
@@ -1562,6 +1562,25 @@ int __sched __rt_mutex_futex_trylock(struct rt_mutex *lock)
return __rt_mutex_slowtrylock(lock);
}
2019-04-08 23:49:20 +00:00
+/**
+ * rt_mutex_lock_killable - lock a rt_mutex killable
+ *
+ * @lock: the rt_mutex to be locked
+ * @detect_deadlock: deadlock detection on/off
+ *
+ * Returns:
+ * 0 on success
+ * -EINTR when interrupted by a signal
+ * -EDEADLK when the lock would deadlock (when deadlock detection is on)
+ */
+int __sched rt_mutex_lock_killable(struct rt_mutex *lock)
+{
+ might_sleep();
+
+ return rt_mutex_fastlock(lock, TASK_KILLABLE, rt_mutex_slowlock);
+}
+EXPORT_SYMBOL_GPL(rt_mutex_lock_killable);
+
2019-04-08 23:49:20 +00:00
/**
* rt_mutex_timed_lock - lock a rt_mutex interruptible
* the timeout structure is provided