linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 1/2] sched/wait: Add wait_event_state_exclusive()
@ 2025-06-10  4:52 Sergey Senozhatsky
  2025-06-10  4:52 ` [PATCHv2 2/2] fuse: use freezable wait in fuse_get_req() Sergey Senozhatsky
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sergey Senozhatsky @ 2025-06-10  4:52 UTC (permalink / raw)
  To: Miklos Szeredi, Peter Zijlstra
  Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Tomasz Figa, linux-fsdevel,
	linux-kernel, Sergey Senozhatsky

Allows exclusive waits with a custom @state.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---

v2: switched to wait_event_state_exclusive()

 include/linux/wait.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 327894f022cf..9ebb0d2e422a 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -968,6 +968,18 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
 		      state, 0, timeout,					\
 		      __ret = schedule_timeout(__ret))
 
+#define __wait_event_state_exclusive(wq, condition, state)			\
+	___wait_event(wq, condition, state, 1, 0, schedule())
+
+#define wait_event_state_exclusive(wq, condition, state)			\
+({										\
+	int __ret = 0;								\
+	might_sleep();								\
+	if (!(condition))							\
+		__ret = __wait_event_state_exclusive(wq, condition, state);	\
+	__ret;									\
+})
+
 #define __wait_event_killable_timeout(wq_head, condition, timeout)		\
 	___wait_event(wq_head, ___wait_cond_timeout(condition),			\
 		      TASK_KILLABLE, 0, timeout,				\
-- 
2.50.0.rc1.591.g9c95f17f64-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-21  3:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10  4:52 [PATCHv2 1/2] sched/wait: Add wait_event_state_exclusive() Sergey Senozhatsky
2025-06-10  4:52 ` [PATCHv2 2/2] fuse: use freezable wait in fuse_get_req() Sergey Senozhatsky
2025-06-19  2:51   ` Sergey Senozhatsky
2025-07-02  5:37   ` Miklos Szeredi
2025-06-13  9:17 ` [PATCHv2 1/2] sched/wait: Add wait_event_state_exclusive() Peter Zijlstra
2025-07-20 20:58 ` Askar Safin
2025-07-21  3:16   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).