From 01573e231f18eb2d99162747186f59511f56b64d Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 08 Dec 2023 10:40:48 +0000
Subject: [PATCH] 移去rt

---
 kernel/kernel/locking/rwsem-rt.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/kernel/kernel/locking/rwsem-rt.c b/kernel/kernel/locking/rwsem-rt.c
index 9669464..b61edc4 100644
--- a/kernel/kernel/locking/rwsem-rt.c
+++ b/kernel/kernel/locking/rwsem-rt.c
@@ -1,10 +1,9 @@
-/*
- */
-#include <linux/blkdev.h>
+// SPDX-License-Identifier: GPL-2.0-only
 #include <linux/rwsem.h>
 #include <linux/sched/debug.h>
 #include <linux/sched/signal.h>
 #include <linux/export.h>
+#include <linux/blkdev.h>
 
 #include "rtmutex_common.h"
 
@@ -88,13 +87,12 @@
 
 	if (__down_read_trylock(sem))
 		return 0;
+
 	/*
-	 * If rt_mutex 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,
-	 * a deadlock in I/O may happen.
+	 * Flush blk before ->pi_blocked_on is set. At schedule() time it is too
+	 * late if one of the callbacks needs to acquire a sleeping lock.
 	 */
-	if (unlikely(blk_needs_flush_plug(current)))
+	if (blk_needs_flush_plug(current))
 		blk_schedule_flush_plug(current);
 
 	might_sleep();
@@ -229,6 +227,13 @@
 	struct rt_mutex *m = &sem->rtmutex;
 	unsigned long flags;
 
+	/*
+	 * Flush blk before ->pi_blocked_on is set. At schedule() time it is too
+	 * late if one of the callbacks needs to acquire a sleeping lock.
+	 */
+	if (blk_needs_flush_plug(current))
+		blk_schedule_flush_plug(current);
+
 	/* Take the rtmutex as a first step */
 	if (__rt_mutex_lock_state(m, state))
 		return -EINTR;

--
Gitblit v1.6.2