]> Gentwo Git Trees - linux/.git/commitdiff
io_uring: move cq/sq user offset init around
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 12 Nov 2025 12:45:59 +0000 (12:45 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 14:27:35 +0000 (07:27 -0700)
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>
io_uring/io_uring.c

index ea5d9e26a10f09a6ecd889ea5a303b9e0460aa5c..1e58fc1d5667a3291f2573861c21d55a05511411 100644 (file)
@@ -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;