aboutsummaryrefslogtreecommitdiff
path: root/io_uring/futex.h
diff options
context:
space:
mode:
authorGravatar Jens Axboe <axboe@kernel.dk> 2023-06-12 19:04:32 -0600
committerGravatar Jens Axboe <axboe@kernel.dk> 2023-09-29 02:37:08 -0600
commit8f350194d5cfd7016d4cd44e433df0faa4d4a703 (patch)
treee8f0e16b7c1c49670594b834b5c5ff248bdc29bb /io_uring/futex.h
parentfutex: make the vectored futex operations available (diff)
downloadlinux-8f350194d5cfd7016d4cd44e433df0faa4d4a703.tar.gz
linux-8f350194d5cfd7016d4cd44e433df0faa4d4a703.tar.bz2
linux-8f350194d5cfd7016d4cd44e433df0faa4d4a703.zip
io_uring: add support for vectored futex waits
This adds support for IORING_OP_FUTEX_WAITV, which allows registering a notification for a number of futexes at once. If one of the futexes are woken, then the request will complete with the index of the futex that got woken as the result. This is identical to what the normal vectored futex waitv operation does. Use like IORING_OP_FUTEX_WAIT, except sqe->addr must now contain a pointer to a struct futex_waitv array, and sqe->off must now contain the number of elements in that array. As flags are passed in the futex_vector array, and likewise for the value and futex address(es), sqe->addr2 and sqe->addr3 are also reserved for IORING_OP_FUTEX_WAITV. For cancelations, FUTEX_WAITV does not rely on the futex_unqueue() return value as we're dealing with multiple futexes. Instead, a separate per io_uring request atomic is used to claim ownership of the request. Waiting on N futexes could be done with IORING_OP_FUTEX_WAIT as well, but that punts a lot of the work to the application: 1) Application would need to submit N IORING_OP_FUTEX_WAIT requests, rather than just a single IORING_OP_FUTEX_WAITV. 2) When one futex is woken, application would need to cancel the remaining N-1 requests that didn't trigger. While this is of course doable, having a single vectored futex wait makes for much simpler application code. Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/futex.h')
-rw-r--r--io_uring/futex.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/io_uring/futex.h b/io_uring/futex.h
index ddc9e0d73c52..0847e9e8a127 100644
--- a/io_uring/futex.h
+++ b/io_uring/futex.h
@@ -3,7 +3,9 @@
#include "cancel.h"
int io_futex_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+int io_futexv_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags);
+int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags);
int io_futex_wake(struct io_kiocb *req, unsigned int issue_flags);
#if defined(CONFIG_FUTEX)