[PATCH 26/29] dept: Apply timeout consideration to wait_for_completion()/complete()

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


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

Now that CONFIG_DEPT_AGGRESSIVE_TIMEOUT_WAIT was introduced, apply the
consideration to wait_for_completion()/complete().

Signed-off-by: Byungchul Park <byungchul.park at lge.com>
Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>
---
 include/linux/completion.h |  6 ++++++
 kernel/sched/completion.c  | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/linux/completion.h b/include/linux/completion.h
index 72adefb4774f..78a84983b7a3 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -38,6 +38,11 @@ do {									\
 	dept_ask_event(m);						\
 	dept_wait(m, 1UL, ip, __func__, 0, true, false);		\
 } while (0)
+#define dept_wfc_wait_timeout(m, ip)					\
+do {									\
+	dept_ask_event(m);						\
+	dept_wait(m, 1UL, ip, __func__, 0, true, true);			\
+} while (0)
 #define dept_wfc_complete(m, ip)		dept_event(m, 1UL, ip, __func__)
 #define dept_wfc_enter(m, ip)			dept_ecxt_enter(m, 1UL, ip, "completion_context_enter", "complete", 0)
 #define dept_wfc_exit(m, ip)			dept_ecxt_exit(m, 1UL, ip)
@@ -46,6 +51,7 @@ do {									\
 #define dept_wfc_init(m, k, s, n)		do { (void)(n); (void)(k); } while (0)
 #define dept_wfc_reinit(m)			do { } while (0)
 #define dept_wfc_wait(m, ip)			do { } while (0)
+#define dept_wfc_wait_timeout(m, ip)		do { } while (0)
 #define dept_wfc_complete(m, ip)		do { } while (0)
 #define dept_wfc_enter(m, ip)			do { } while (0)
 #define dept_wfc_exit(m, ip)			do { } while (0)
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 8914ac566100..a0e2c627148b 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -126,10 +126,22 @@ _wait_for_common_io(struct completion *x, long timeout, int state)
 }
 
 #define wait_for_common(x, t, s)					\
-({ dept_wfc_wait(&(x)->dmap, _RET_IP_); _wait_for_common(x, t, s); })
+({									\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)				\
+		dept_wfc_wait(&(x)->dmap, _RET_IP_);			\
+	else								\
+		dept_wfc_wait_timeout(&(x)->dmap, _RET_IP_);		\
+	_wait_for_common(x, t, s);					\
+})
 
 #define wait_for_common_io(x, t, s)					\
-({ dept_wfc_wait(&(x)->dmap, _RET_IP_); _wait_for_common_io(x, t, s); })
+({									\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)				\
+		dept_wfc_wait(&(x)->dmap, _RET_IP_);			\
+	else								\
+		dept_wfc_wait_timeout(&(x)->dmap, _RET_IP_);		\
+	_wait_for_common_io(x, t, s);					\
+})
 
 /**
  * wait_for_completion: - waits for completion of a task
-- 
2.37.1



More information about the Intel-gfx-trybot mailing list