Files
linuxkit/kernel/patches-4.14.x-rt/0250-rtmutex-Add-rtmutex_lock_killable.patch
Tiejun Chen a1d47ff766 update -rt to 4.14.53-rt34
Signed-off-by: Tiejun Chen <tiejun.china@gmail.com>
2018-07-06 14:02:07 +08:00

60 lines
1.9 KiB
Diff

From e4db3478b6391020f01b182736f1d6d7f35661a3 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 9 Jun 2011 11:43:52 +0200
Subject: [PATCH 250/418] rtmutex: Add rtmutex_lock_killable()
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>
---
include/linux/rtmutex.h | 1 +
kernel/locking/rtmutex.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 1b92a28dd672..66aa13520b68 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -108,6 +108,7 @@ extern void rt_mutex_destroy(struct rt_mutex *lock);
extern void rt_mutex_lock(struct rt_mutex *lock);
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);
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index bbb3508d267f..986620b78011 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1542,6 +1542,25 @@ int __sched __rt_mutex_futex_trylock(struct rt_mutex *lock)
return __rt_mutex_slowtrylock(lock);
}
+/**
+ * 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);
+
/**
* rt_mutex_timed_lock - lock a rt_mutex interruptible
* the timeout structure is provided
--
2.17.1