Skip to contentSkip to conversation

Add a new helper for sleepable BTM acquirements which is used by tty_write_message()

PATCH NAK Jeff Liu 2 participants 2 messages Jun 30, 2012

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/2 Add a new helper for sleepable BTM acquirements which is used by tty_write_message()

This helper only used by tty_write_message(), it will sleep until BTM lock acquired.

---
 drivers/tty/tty_mutex.c |   13 +++++++++++++
 include/linux/tty.h     |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/tty/tty_mutex.c +13 -0
index 9ff986c..e638636 100644
@@ -30,3 +30,16 @@ void __lockfunc tty_unlock(void)
 	mutex_unlock(&big_tty_mutex);
 }
 EXPORT_SYMBOL(tty_unlock);
+
+/*
+ * Wait until getting the big tty mutex.
+ * This function only used by tty_write_message().
+ */
+void __lockfunc tty_lock_wait(void)
+{
+	while (!mutex_trylock(&big_tty_mutex)) {
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule();
+	}
+}
+EXPORT_SYMBOL(tty_lock_wait);
include/linux/tty.h +1 -0
index 9f47ab5..5e01e0b 100644
@@ -607,6 +607,7 @@ extern long vt_compat_ioctl(struct tty_struct *tty,
 /* functions for preparation of BKL removal */
 extern void __lockfunc tty_lock(void) __acquires(tty_lock);
 extern void __lockfunc tty_unlock(void) __releases(tty_lock);
+extern void __lockfunc tty_lock_wait(void) __acquires(tty_lock);
 
 /*
  * this shall be called only from where BTM is held (like close)
Signature · 1 line
1.7.9
#1 lore raw
Quoted 1 line · On Sat, 30 Jun 2012 17:39:58 +0800 Jeff Liu <[email protected]> wrote:

This helper only used by tty_write_message(), it will sleep until BTM lock acquired.

This makes no sense at all. mutexes already sleep. Your code is also wrong for real time processes.

So NAK.