diff mbox

[2/3] rtmutex: introduce rt_mutex_lock_irqdisabled()

Message ID 20111206032845.GB17091@zhy
State New
Headers show

Commit Message

Yong Zhang Dec. 6, 2011, 3:28 a.m. UTC
Since we permit rt_mutex_lock() to be called with irq disabled
in commit 5342e269, and we will call might_sleep() in
rt_mutex_lock() unconditionally, false positive will be
made. So introduce rt_mutex_lock_irqdisabled() for that kind
of usage.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
---
 include/linux/rtmutex.h |    1 +
 kernel/rtmutex.c        |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index de17134..0732a25 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -88,6 +88,7 @@  extern void __rt_mutex_init(struct rt_mutex *lock, const char *name);
 extern void rt_mutex_destroy(struct rt_mutex *lock);
 
 extern void rt_mutex_lock(struct rt_mutex *lock);
+extern void rt_mutex_lock_irqdisabled(struct rt_mutex *lock);
 extern int rt_mutex_lock_interruptible(struct rt_mutex *lock,
 						int detect_deadlock);
 extern int rt_mutex_timed_lock(struct rt_mutex *lock,
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index f9d8482..961a100 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -797,6 +797,19 @@  void __sched rt_mutex_lock(struct rt_mutex *lock)
 EXPORT_SYMBOL_GPL(rt_mutex_lock);
 
 /**
+ * rt_mutex_lock_irqdisabled - lock a rt_mutex with irq disabled
+ *
+ * @lock: the rt_mutex to be locked
+ */
+void __sched rt_mutex_lock_irqdisabled(struct rt_mutex *lock)
+{
+	might_sleep_irqdisabled();
+
+	rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, 0, rt_mutex_slowlock);
+}
+EXPORT_SYMBOL_GPL(rt_mutex_lock_irqdisabled);
+
+/**
  * rt_mutex_lock_interruptible - lock a rt_mutex interruptible
  *
  * @lock: 		the rt_mutex to be locked