linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RT] rtmutex: Flush block plug on __down_read()
@ 2019-01-04 20:33 Scott Wood
  2019-01-07 16:50 ` Sebastian Andrzej Siewior
  2019-01-09  9:48 ` Sebastian Andrzej Siewior
  0 siblings, 2 replies; 5+ messages in thread
From: Scott Wood @ 2019-01-04 20:33 UTC (permalink / raw)
  To: Thomas Gleixner, Sebastian Andrzej Siewior
  Cc: Mikulas Patocka, linux-rt-users, linux-kernel, Scott Wood

__down_read() bypasses the rtmutex frontend to call
rt_mutex_slowlock_locked() directly, and thus it needs to call
blk_schedule_flush_flug() itself.

Signed-off-by: Scott Wood <swood@redhat.com>
---
 kernel/locking/rwsem-rt.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/locking/rwsem-rt.c b/kernel/locking/rwsem-rt.c
index 660e22caf709..f73cd4eda5cd 100644
--- a/kernel/locking/rwsem-rt.c
+++ b/kernel/locking/rwsem-rt.c
@@ -1,5 +1,6 @@
 /*
  */
+#include <linux/blkdev.h>
 #include <linux/rwsem.h>
 #include <linux/sched/debug.h>
 #include <linux/sched/signal.h>
@@ -88,6 +89,15 @@ static int __sched __down_read_common(struct rw_semaphore *sem, int state)
 	if (__down_read_trylock(sem))
 		return 0;
 
+	/*
+	 * If sem->rtmutex blocks, the function sched_submit_work will not
+	 * call blk_schedule_flush_plug (because tsk_is_pi_blocked would be
+	 * true).  We must call blk_schedule_flush_plug here; if we don't
+	 * call it, an I/O deadlock may occur.
+	 */
+	if (unlikely(blk_needs_flush_plug(current)))
+		blk_schedule_flush_plug(current);
+
 	might_sleep();
 	raw_spin_lock_irq(&m->wait_lock);
 	/*
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-09  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-04 20:33 [PATCH RT] rtmutex: Flush block plug on __down_read() Scott Wood
2019-01-07 16:50 ` Sebastian Andrzej Siewior
2019-01-08 19:19   ` Scott Wood
2019-01-09  8:31     ` Sebastian Andrzej Siewior
2019-01-09  9:48 ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).