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/rsrc: replace reg buffer bit field with flags

I'll need a flag in the registered buffer struct for dmabuf work, and
it'll be more convenient to have a flags field rather than bit fields,
especially for io_mapped_ubuf initialisation.

We might want to add more flags in the future as well. For example, it
might be useful for debugging and potentially optimisations to split out
a flag indicating the shape of the buffer to gate iov_iter_advance()
walks vs bit/mask arithmetics. It can also be combined with the
direction mask field.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
0efc331d 417d029d

+13 -8
+6 -6
io_uring/rsrc.c
··· 828 828 imu->folio_shift = PAGE_SHIFT; 829 829 imu->release = io_release_ubuf; 830 830 imu->priv = imu; 831 - imu->is_kbuf = false; 831 + imu->flags = 0; 832 832 imu->dir = IO_IMU_DEST | IO_IMU_SOURCE; 833 833 if (coalesced) 834 834 imu->folio_shift = data.folio_shift; ··· 985 985 refcount_set(&imu->refs, 1); 986 986 imu->release = release; 987 987 imu->priv = rq; 988 - imu->is_kbuf = true; 988 + imu->flags = IO_REGBUF_F_KBUF; 989 989 imu->dir = 1 << rq_data_dir(rq); 990 990 991 991 rq_for_each_bvec(bv, rq, rq_iter) ··· 1020 1020 ret = -EINVAL; 1021 1021 goto unlock; 1022 1022 } 1023 - if (!node->buf->is_kbuf) { 1023 + if (!(node->buf->flags & IO_REGBUF_F_KBUF)) { 1024 1024 ret = -EBUSY; 1025 1025 goto unlock; 1026 1026 } ··· 1076 1076 1077 1077 offset = buf_addr - imu->ubuf; 1078 1078 1079 - if (imu->is_kbuf) 1079 + if (imu->flags & IO_REGBUF_F_KBUF) 1080 1080 return io_import_kbuf(ddir, iter, imu, len, offset); 1081 1081 1082 1082 /* ··· 1496 1496 iovec_off = vec->nr - nr_iovs; 1497 1497 iov = vec->iovec + iovec_off; 1498 1498 1499 - if (imu->is_kbuf) { 1499 + if (imu->flags & IO_REGBUF_F_KBUF) { 1500 1500 int ret = io_kern_bvec_size(iov, nr_iovs, imu, &nr_segs); 1501 1501 1502 1502 if (unlikely(ret)) ··· 1534 1534 req->flags |= REQ_F_NEED_CLEANUP; 1535 1535 } 1536 1536 1537 - if (imu->is_kbuf) 1537 + if (imu->flags & IO_REGBUF_F_KBUF) 1538 1538 return io_vec_fill_kern_bvec(ddir, iter, imu, iov, nr_iovs, vec); 1539 1539 1540 1540 return io_vec_fill_bvec(ddir, iter, imu, iov, nr_iovs, vec);
+5 -1
io_uring/rsrc.h
··· 28 28 IO_IMU_SOURCE = 1 << ITER_SOURCE, 29 29 }; 30 30 31 + enum { 32 + IO_REGBUF_F_KBUF = 1, 33 + }; 34 + 31 35 struct io_mapped_ubuf { 32 36 u64 ubuf; 33 37 unsigned int len; ··· 41 37 unsigned long acct_pages; 42 38 void (*release)(void *); 43 39 void *priv; 44 - bool is_kbuf; 40 + u8 flags; 45 41 u8 dir; 46 42 struct bio_vec bvec[] __counted_by(nr_bvecs); 47 43 };
+2 -1
io_uring/rw.c
··· 702 702 if ((kiocb->ki_flags & IOCB_NOWAIT) && 703 703 !(kiocb->ki_filp->f_flags & O_NONBLOCK)) 704 704 return -EAGAIN; 705 - if ((req->flags & REQ_F_BUF_NODE) && req->buf_node->buf->is_kbuf) 705 + if ((req->flags & REQ_F_BUF_NODE) && 706 + (req->buf_node->buf->flags & IO_REGBUF_F_KBUF)) 706 707 return -EFAULT; 707 708 708 709 ppos = io_kiocb_ppos(kiocb);