diff options
| author | Pavel Begunkov <asml.silence@gmail.com> | 2025-11-12 12:45:59 +0000 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2025-11-13 07:27:35 -0700 |
| commit | d741c6255524f0691aea53381219fadcd2b38408 (patch) | |
| tree | f37d340f9dc1868cd0d8ecf3a7b813c73b327b00 | |
| parent | eb76ff6a6829a9a54a385804cc9dbe4460f156d6 (diff) | |
io_uring: move cq/sq user offset init around
Move user SQ/CQ offset initialisation at the end of io_prepare_config()
where it already calculated all information to set it properly.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
| -rw-r--r-- | io_uring/io_uring.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index ea5d9e26a10f..1e58fc1d5667 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3519,27 +3519,6 @@ static int io_uring_fill_params(struct io_uring_params *p) p->cq_entries = 2 * p->sq_entries; } - p->sq_off.head = offsetof(struct io_rings, sq.head); - p->sq_off.tail = offsetof(struct io_rings, sq.tail); - p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask); - p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries); - p->sq_off.flags = offsetof(struct io_rings, sq_flags); - p->sq_off.dropped = offsetof(struct io_rings, sq_dropped); - p->sq_off.resv1 = 0; - if (!(p->flags & IORING_SETUP_NO_MMAP)) - p->sq_off.user_addr = 0; - - p->cq_off.head = offsetof(struct io_rings, cq.head); - p->cq_off.tail = offsetof(struct io_rings, cq.tail); - p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask); - p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); - p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); - p->cq_off.cqes = offsetof(struct io_rings, cqes); - p->cq_off.flags = offsetof(struct io_rings, cq_flags); - p->cq_off.resv1 = 0; - if (!(p->flags & IORING_SETUP_NO_MMAP)) - p->cq_off.user_addr = 0; - return 0; } @@ -3561,6 +3540,26 @@ int io_prepare_config(struct io_ctx_config *config) if (ret) return ret; + p->sq_off.head = offsetof(struct io_rings, sq.head); + p->sq_off.tail = offsetof(struct io_rings, sq.tail); + p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask); + p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries); + p->sq_off.flags = offsetof(struct io_rings, sq_flags); + p->sq_off.dropped = offsetof(struct io_rings, sq_dropped); + p->sq_off.resv1 = 0; + if (!(p->flags & IORING_SETUP_NO_MMAP)) + p->sq_off.user_addr = 0; + + p->cq_off.head = offsetof(struct io_rings, cq.head); + p->cq_off.tail = offsetof(struct io_rings, cq.tail); + p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask); + p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); + p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); + p->cq_off.cqes = offsetof(struct io_rings, cqes); + p->cq_off.flags = offsetof(struct io_rings, cq_flags); + p->cq_off.resv1 = 0; + if (!(p->flags & IORING_SETUP_NO_MMAP)) + p->cq_off.user_addr = 0; if (!(p->flags & IORING_SETUP_NO_SQARRAY)) p->sq_off.array = config->layout.sq_array_offset; |
