Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: abstract out a bit of the ring filling logic

Abstract out a io_uring_fill_params() helper, which fills out the
necessary bits of struct io_uring_params. Add it to io_uring.h as well,
in preparation for having another internal user of it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+41 -30
+40 -30
io_uring/io_uring.c
··· 3498 3498 O_RDWR | O_CLOEXEC, NULL); 3499 3499 } 3500 3500 3501 - static __cold int io_uring_create(unsigned entries, struct io_uring_params *p, 3502 - struct io_uring_params __user *params) 3501 + int io_uring_fill_params(unsigned entries, struct io_uring_params *p) 3503 3502 { 3504 - struct io_ring_ctx *ctx; 3505 - struct io_uring_task *tctx; 3506 - struct file *file; 3507 - int ret; 3508 - 3509 3503 if (!entries) 3510 3504 return -EINVAL; 3511 3505 if (entries > IORING_MAX_ENTRIES) { ··· 3540 3546 } else { 3541 3547 p->cq_entries = 2 * p->sq_entries; 3542 3548 } 3549 + 3550 + p->sq_off.head = offsetof(struct io_rings, sq.head); 3551 + p->sq_off.tail = offsetof(struct io_rings, sq.tail); 3552 + p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask); 3553 + p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries); 3554 + p->sq_off.flags = offsetof(struct io_rings, sq_flags); 3555 + p->sq_off.dropped = offsetof(struct io_rings, sq_dropped); 3556 + p->sq_off.resv1 = 0; 3557 + if (!(p->flags & IORING_SETUP_NO_MMAP)) 3558 + p->sq_off.user_addr = 0; 3559 + 3560 + p->cq_off.head = offsetof(struct io_rings, cq.head); 3561 + p->cq_off.tail = offsetof(struct io_rings, cq.tail); 3562 + p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask); 3563 + p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); 3564 + p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); 3565 + p->cq_off.cqes = offsetof(struct io_rings, cqes); 3566 + p->cq_off.flags = offsetof(struct io_rings, cq_flags); 3567 + p->cq_off.resv1 = 0; 3568 + if (!(p->flags & IORING_SETUP_NO_MMAP)) 3569 + p->cq_off.user_addr = 0; 3570 + 3571 + return 0; 3572 + } 3573 + 3574 + static __cold int io_uring_create(unsigned entries, struct io_uring_params *p, 3575 + struct io_uring_params __user *params) 3576 + { 3577 + struct io_ring_ctx *ctx; 3578 + struct io_uring_task *tctx; 3579 + struct file *file; 3580 + int ret; 3581 + 3582 + ret = io_uring_fill_params(entries, p); 3583 + if (unlikely(ret)) 3584 + return ret; 3543 3585 3544 3586 ctx = io_ring_ctx_alloc(p); 3545 3587 if (!ctx) ··· 3660 3630 if (ret) 3661 3631 goto err; 3662 3632 3633 + if (!(p->flags & IORING_SETUP_NO_SQARRAY)) 3634 + p->sq_off.array = (char *)ctx->sq_array - (char *)ctx->rings; 3635 + 3663 3636 ret = io_sq_offload_create(ctx, p); 3664 3637 if (ret) 3665 3638 goto err; ··· 3670 3637 ret = io_rsrc_init(ctx); 3671 3638 if (ret) 3672 3639 goto err; 3673 - 3674 - p->sq_off.head = offsetof(struct io_rings, sq.head); 3675 - p->sq_off.tail = offsetof(struct io_rings, sq.tail); 3676 - p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask); 3677 - p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries); 3678 - p->sq_off.flags = offsetof(struct io_rings, sq_flags); 3679 - p->sq_off.dropped = offsetof(struct io_rings, sq_dropped); 3680 - if (!(ctx->flags & IORING_SETUP_NO_SQARRAY)) 3681 - p->sq_off.array = (char *)ctx->sq_array - (char *)ctx->rings; 3682 - p->sq_off.resv1 = 0; 3683 - if (!(ctx->flags & IORING_SETUP_NO_MMAP)) 3684 - p->sq_off.user_addr = 0; 3685 - 3686 - p->cq_off.head = offsetof(struct io_rings, cq.head); 3687 - p->cq_off.tail = offsetof(struct io_rings, cq.tail); 3688 - p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask); 3689 - p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); 3690 - p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); 3691 - p->cq_off.cqes = offsetof(struct io_rings, cqes); 3692 - p->cq_off.flags = offsetof(struct io_rings, cq_flags); 3693 - p->cq_off.resv1 = 0; 3694 - if (!(ctx->flags & IORING_SETUP_NO_MMAP)) 3695 - p->cq_off.user_addr = 0; 3696 3640 3697 3641 p->features = IORING_FEAT_SINGLE_MMAP | IORING_FEAT_NODROP | 3698 3642 IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |
+1
io_uring/io_uring.h
··· 70 70 71 71 unsigned long rings_size(unsigned int flags, unsigned int sq_entries, 72 72 unsigned int cq_entries, size_t *sq_offset); 73 + int io_uring_fill_params(unsigned entries, struct io_uring_params *p); 73 74 bool io_cqe_cache_refill(struct io_ring_ctx *ctx, bool overflow); 74 75 int io_run_task_work_sig(struct io_ring_ctx *ctx); 75 76 void io_req_defer_failed(struct io_kiocb *req, s32 res);