Skip to contentSkip to conversation

rcuwait: Add might_sleep() annotations

PATCH In review Davidlohr Bueso 2 participants 3 messages Jul 24, 2023 – Jul 25, 2023 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcuwait: Add might_sleep() annotations

... as with regular waitqueues.

---
 include/linux/rcuwait.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/rcuwait.h +5 -1
index 27343424225c..c0fcac903d03 100644
@@ -74,7 +74,10 @@ extern void finish_rcuwait(struct rcuwait *w);
 })
 
 #define rcuwait_wait_event(w, condition, state)				\
-	___rcuwait_wait_event(w, condition, state, 0, schedule())
+do {									\
+	might_sleep();							\
+	___rcuwait_wait_event(w, condition, state, 0, schedule());	\
+} while (0)
 
 #define __rcuwait_wait_event_timeout(w, condition, state, timeout)	\
 	___rcuwait_wait_event(w, ___wait_cond_timeout(condition),	\
@@ -84,6 +87,7 @@ extern void finish_rcuwait(struct rcuwait *w);
 #define rcuwait_wait_event_timeout(w, condition, state, timeout)	\
 ({									\
 	long __ret = timeout;						\
+	might_sleep();							\
 	if (!___wait_cond_timeout(condition))				\
 		__ret = __rcuwait_wait_event_timeout(w, condition,	\
 						     state, timeout);	\
Signature · 1 line
2.41.0
#1 lore raw
Quoted 1 line · Davidlohr Bueso

... as with regular waitqueues.

No immediate objection, but please, tell us more. What made you get up this fine morning and write this patch?

Quoted 32 lines
---
 include/linux/rcuwait.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/rcuwait.h +5 -1
index 27343424225c..c0fcac903d03 100644
@@ -74,7 +74,10 @@ extern void finish_rcuwait(struct rcuwait *w);
 })
 
 #define rcuwait_wait_event(w, condition, state)				\
-	___rcuwait_wait_event(w, condition, state, 0, schedule())
+do {									\
+	might_sleep();							\
+	___rcuwait_wait_event(w, condition, state, 0, schedule());	\
+} while (0)
 
 #define __rcuwait_wait_event_timeout(w, condition, state, timeout)	\
 	___rcuwait_wait_event(w, ___wait_cond_timeout(condition),	\
@@ -84,6 +87,7 @@ extern void finish_rcuwait(struct rcuwait *w);
 #define rcuwait_wait_event_timeout(w, condition, state, timeout)	\
 ({									\
 	long __ret = timeout;						\
+	might_sleep();							\
 	if (!___wait_cond_timeout(condition))				\
 		__ret = __rcuwait_wait_event_timeout(w, condition,	\
 						     state, timeout);	\
Signature · 1 line
2.41.0
#2 lore raw
Quoted 5 lines · Peter Zijlstra
Quoted 1 line · Davidlohr Bueso

... as with regular waitqueues.

No immediate objection, but please, tell us more. What made you get up this fine morning and write this patch?

So this was just something I had noticed missing while adding the timeout support.

Thanks,
Davidlohr