[PATCH RFC v7 18/23] dept: Apply timeout consideration to wait_for_completion()/complete()

Byungchul Park byungchul.park at lge.com
Mon Jan 9 03:33:46 UTC 2023


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>
---
 include/linux/completion.h | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/completion.h b/include/linux/completion.h
index 0408f6d..57a715f 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -11,6 +11,7 @@
 
 #include <linux/swait.h>
 #include <linux/dept_sdt.h>
+#include <linux/sched.h>
 
 /*
  * struct completion - structure used to maintain state for a "completion"
@@ -153,7 +154,10 @@ extern long raw_wait_for_completion_killable_timeout(
 #define wait_for_completion_timeout(x, t)			\
 ({								\
 	unsigned long __ret;					\
-	sdt_might_sleep_strong(NULL);				\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)			\
+		sdt_might_sleep_strong(NULL);			\
+	else							\
+		sdt_might_sleep_strong_timeout(NULL);		\
 	__ret = raw_wait_for_completion_timeout(x, t);		\
 	sdt_might_sleep_finish();				\
 	__ret;							\
@@ -161,7 +165,10 @@ extern long raw_wait_for_completion_killable_timeout(
 #define wait_for_completion_io_timeout(x, t)			\
 ({								\
 	unsigned long __ret;					\
-	sdt_might_sleep_strong(NULL);				\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)			\
+		sdt_might_sleep_strong(NULL);			\
+	else							\
+		sdt_might_sleep_strong_timeout(NULL);		\
 	__ret = raw_wait_for_completion_io_timeout(x, t);	\
 	sdt_might_sleep_finish();				\
 	__ret;							\
@@ -169,7 +176,10 @@ extern long raw_wait_for_completion_killable_timeout(
 #define wait_for_completion_interruptible_timeout(x, t)		\
 ({								\
 	long __ret;						\
-	sdt_might_sleep_strong(NULL);				\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)			\
+		sdt_might_sleep_strong(NULL);			\
+	else							\
+		sdt_might_sleep_strong_timeout(NULL);		\
 	__ret = raw_wait_for_completion_interruptible_timeout(x, t);\
 	sdt_might_sleep_finish();				\
 	__ret;							\
@@ -177,7 +187,10 @@ extern long raw_wait_for_completion_killable_timeout(
 #define wait_for_completion_killable_timeout(x, t)		\
 ({								\
 	long __ret;						\
-	sdt_might_sleep_strong(NULL);				\
+	if ((t) == MAX_SCHEDULE_TIMEOUT)			\
+		sdt_might_sleep_strong(NULL);			\
+	else							\
+		sdt_might_sleep_strong_timeout(NULL);		\
 	__ret = raw_wait_for_completion_killable_timeout(x, t);	\
 	sdt_might_sleep_finish();				\
 	__ret;							\
-- 
1.9.1



More information about the dri-devel mailing list