blob: 0cfd124ce7e5c34954dda849d7da8f904c923db1 [file] [log] [blame]
Arvind M8e87d852018-01-29 00:04:29 -08001From fbbe78885fc3a4fa1a0dab152eaea7ff1c8a60cb Mon Sep 17 00:00:00 2001
Allen Martin685e0f82016-07-26 19:34:29 -07002From: Thomas Gleixner <tglx@linutronix.de>
3Date: Thu, 9 Jun 2011 11:43:52 +0200
Arvind M10268e72017-12-04 22:18:06 -08004Subject: [PATCH 120/366] rtmutex: Add rtmutex_lock_killable()
Allen Martin685e0f82016-07-26 19:34:29 -07005
6Add "killable" type to rtmutex. We need this since rtmutex are used as
7"normal" mutexes which do use this type.
8
9Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Allen Martin685e0f82016-07-26 19:34:29 -070010---
11 include/linux/rtmutex.h | 1 +
12 kernel/locking/rtmutex.c | 19 +++++++++++++++++++
13 2 files changed, 20 insertions(+)
14
15diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
Ishan Mittalb7998262017-01-17 16:11:50 +053016index 1abba5c..51dc12e 100644
Allen Martin685e0f82016-07-26 19:34:29 -070017--- a/include/linux/rtmutex.h
18+++ b/include/linux/rtmutex.h
19@@ -91,6 +91,7 @@ extern void rt_mutex_destroy(struct rt_mutex *lock);
20
21 extern void rt_mutex_lock(struct rt_mutex *lock);
22 extern int rt_mutex_lock_interruptible(struct rt_mutex *lock);
23+extern int rt_mutex_lock_killable(struct rt_mutex *lock);
24 extern int rt_mutex_timed_lock(struct rt_mutex *lock,
25 struct hrtimer_sleeper *timeout);
26
27diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
Ishan Mittalb7998262017-01-17 16:11:50 +053028index f032647..d75967b 100644
Allen Martin685e0f82016-07-26 19:34:29 -070029--- a/kernel/locking/rtmutex.c
30+++ b/kernel/locking/rtmutex.c
Allen Martinfc468d82016-11-15 17:57:52 -080031@@ -1458,6 +1458,25 @@ int rt_mutex_timed_futex_lock(struct rt_mutex *lock,
Allen Martin685e0f82016-07-26 19:34:29 -070032 }
33
34 /**
35+ * rt_mutex_lock_killable - lock a rt_mutex killable
36+ *
37+ * @lock: the rt_mutex to be locked
38+ * @detect_deadlock: deadlock detection on/off
39+ *
40+ * Returns:
41+ * 0 on success
42+ * -EINTR when interrupted by a signal
43+ * -EDEADLK when the lock would deadlock (when deadlock detection is on)
44+ */
45+int __sched rt_mutex_lock_killable(struct rt_mutex *lock)
46+{
47+ might_sleep();
48+
49+ return rt_mutex_fastlock(lock, TASK_KILLABLE, rt_mutex_slowlock);
50+}
51+EXPORT_SYMBOL_GPL(rt_mutex_lock_killable);
52+
53+/**
54 * rt_mutex_timed_lock - lock a rt_mutex interruptible
55 * the timeout structure is provided
56 * by the caller
57--
Arvind M10268e72017-12-04 22:18:06 -0800581.9.1
Allen Martin685e0f82016-07-26 19:34:29 -070059