[PATCH 21/29] dept: Unstage wait when tagging a normal sleep wait

Gwan-gyeong Mun gwan-gyeong.mun at intel.com
Sun Nov 20 10:04:01 UTC 2022


From: Byungchul Park <byungchul.park at lge.com>

Staging a wait and commit have been introduced to handle conditional
sleeps that can be determined in __schedule() whether it actually goes
to sleep or not. With this feature, actual wait tagging is delayed
until __schedule().

Unfortunately, an ambiguity arises when a normal sleep wait that doesn't
require staging and commit, is involved in the middle of handling a
conditional sleep e.g. between prepare_to_wait_*() and __schedule(),
which is a very rare case tho.

So let it give up handling the conditional sleep by unstaging it
unconditionally when a normal sleep wait gets involved, to avoid the
ambiguity.

Signed-off-by: Byungchul Park <byungchul.park at lge.com>
Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>
---
 kernel/dependency/dept.c | 55 +++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 15 deletions(-)

diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c
index 465a1d7668f0..1abc0414dd8f 100644
--- a/kernel/dependency/dept.c
+++ b/kernel/dependency/dept.c
@@ -2196,6 +2196,21 @@ static void __dept_wait(struct dept_map *m, unsigned long w_f,
 	}
 }
 
+static inline void stage_map(struct dept_task *dt, struct dept_map *m)
+{
+	dt->stage_m = m;
+}
+
+static inline void unstage_map(struct dept_task *dt)
+{
+	dt->stage_m = NULL;
+}
+
+static inline struct dept_map *staged_map(struct dept_task *dt)
+{
+	return dt->stage_m;
+}
+
 void dept_wait(struct dept_map *m, unsigned long w_f, unsigned long ip,
 	       const char *w_fn, int ne, bool sleep)
 {
@@ -2213,27 +2228,24 @@ void dept_wait(struct dept_map *m, unsigned long w_f, unsigned long ip,
 
 	flags = dept_enter();
 
+	/*
+	 * There's no way to distinguish between a staged wait and this
+	 * one, in the middle of handling a wait that requires staging
+	 * and commit in __schedule().
+	 *
+	 * The wait that has been tagged dept_wait() with sleep == true
+	 * should ignore the staged wait in __schedule() if it exists,
+	 * to avoid the ambiguity. It can be done by unstaging it.
+	 */
+	if (sleep)
+		unstage_map(dt);
+
 	__dept_wait(m, w_f, ip, w_fn, ne, sleep);
 
 	dept_exit(flags);
 }
 EXPORT_SYMBOL_GPL(dept_wait);
 
-static inline void stage_map(struct dept_task *dt, struct dept_map *m)
-{
-	dt->stage_m = m;
-}
-
-static inline void unstage_map(struct dept_task *dt)
-{
-	dt->stage_m = NULL;
-}
-
-static inline struct dept_map *staged_map(struct dept_task *dt)
-{
-	return dt->stage_m;
-}
-
 void dept_stage_wait(struct dept_map *m, unsigned long w_f,
 		     const char *w_fn, int ne)
 {
@@ -2597,6 +2609,19 @@ void dept_wait_split_map(struct dept_map_each *me,
 
 	flags = dept_enter();
 
+	/*
+	 * There's no way to distinguish between a staged wait and this
+	 * one, in the middle of handling a wait that requires staging
+	 * and commit in __schedule().
+	 *
+	 * The wait that has been tagged dept_wait_split_map() with
+	 * sleep == true should ignore the staged wait in __schedule()
+	 * if it exists, to avoid the ambiguity. It can be done by
+	 * unstaging it.
+	 */
+	if (sleep)
+		unstage_map(dt);
+
 	k = mc->keys ?: &mc->keys_local;
 	c = check_new_class(&mc->keys_local, k, 0, 0UL, mc->name);
 	if (c)
-- 
2.37.1



More information about the Intel-gfx-trybot mailing list