]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wait: Introduce io_wait_event_killable()
authorRemi Pommarel <repk@triplefau.lt>
Fri, 23 Jan 2026 14:48:07 +0000 (15:48 +0100)
committerDominique Martinet <asmadeus@codewreck.org>
Thu, 29 Jan 2026 07:33:35 +0000 (07:33 +0000)
Add io_wait_event_killable(), a variant of wait_event_killable() that
uses io_schedule() instead of schedule(). This is to be used in
situation where waiting time is to be accounted as IO wait time.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Message-ID: <1b2870001ecd34fe6c05be2ddfefb3c798b11701.1769179462.git.repk@triplefau.lt>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
include/linux/wait.h

index f648044466d5f55f2d65a3aa153b4dfe39f0b6dc..dce055e6add39083642ccbf324709b7493b9a8b3 100644 (file)
@@ -937,6 +937,21 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
        __ret;                                                                  \
 })
 
+#define __io_wait_event_killable(wq, condition)                                        \
+       ___wait_event(wq, condition, TASK_KILLABLE, 0, 0, io_schedule())
+
+/*
+ * wait_event_killable() - link wait_event_killable but with io_schedule()
+ */
+#define io_wait_event_killable(wq_head, condition)                             \
+({                                                                             \
+       int __ret = 0;                                                          \
+       might_sleep();                                                          \
+       if (!(condition))                                                       \
+               __ret = __io_wait_event_killable(wq_head, condition);           \
+       __ret;                                                                  \
+})
+
 #define __wait_event_state(wq, condition, state)                               \
        ___wait_event(wq, condition, state, 0, 0, schedule())