Skip to content

Commit d741c62

Browse files
isilenceaxboe
authored andcommitted
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>
1 parent eb76ff6 commit d741c62

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

io_uring/io_uring.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,27 +3519,6 @@ static int io_uring_fill_params(struct io_uring_params *p)
35193519
p->cq_entries = 2 * p->sq_entries;
35203520
}
35213521

3522-
p->sq_off.head = offsetof(struct io_rings, sq.head);
3523-
p->sq_off.tail = offsetof(struct io_rings, sq.tail);
3524-
p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask);
3525-
p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries);
3526-
p->sq_off.flags = offsetof(struct io_rings, sq_flags);
3527-
p->sq_off.dropped = offsetof(struct io_rings, sq_dropped);
3528-
p->sq_off.resv1 = 0;
3529-
if (!(p->flags & IORING_SETUP_NO_MMAP))
3530-
p->sq_off.user_addr = 0;
3531-
3532-
p->cq_off.head = offsetof(struct io_rings, cq.head);
3533-
p->cq_off.tail = offsetof(struct io_rings, cq.tail);
3534-
p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask);
3535-
p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries);
3536-
p->cq_off.overflow = offsetof(struct io_rings, cq_overflow);
3537-
p->cq_off.cqes = offsetof(struct io_rings, cqes);
3538-
p->cq_off.flags = offsetof(struct io_rings, cq_flags);
3539-
p->cq_off.resv1 = 0;
3540-
if (!(p->flags & IORING_SETUP_NO_MMAP))
3541-
p->cq_off.user_addr = 0;
3542-
35433522
return 0;
35443523
}
35453524

@@ -3561,6 +3540,26 @@ int io_prepare_config(struct io_ctx_config *config)
35613540
if (ret)
35623541
return ret;
35633542

3543+
p->sq_off.head = offsetof(struct io_rings, sq.head);
3544+
p->sq_off.tail = offsetof(struct io_rings, sq.tail);
3545+
p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask);
3546+
p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries);
3547+
p->sq_off.flags = offsetof(struct io_rings, sq_flags);
3548+
p->sq_off.dropped = offsetof(struct io_rings, sq_dropped);
3549+
p->sq_off.resv1 = 0;
3550+
if (!(p->flags & IORING_SETUP_NO_MMAP))
3551+
p->sq_off.user_addr = 0;
3552+
3553+
p->cq_off.head = offsetof(struct io_rings, cq.head);
3554+
p->cq_off.tail = offsetof(struct io_rings, cq.tail);
3555+
p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask);
3556+
p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries);
3557+
p->cq_off.overflow = offsetof(struct io_rings, cq_overflow);
3558+
p->cq_off.cqes = offsetof(struct io_rings, cqes);
3559+
p->cq_off.flags = offsetof(struct io_rings, cq_flags);
3560+
p->cq_off.resv1 = 0;
3561+
if (!(p->flags & IORING_SETUP_NO_MMAP))
3562+
p->cq_off.user_addr = 0;
35643563
if (!(p->flags & IORING_SETUP_NO_SQARRAY))
35653564
p->sq_off.array = config->layout.sq_array_offset;
35663565

0 commit comments

Comments
 (0)