Skip to content

Commit 80c7378

Browse files
nj-shettyaxboe
authored andcommitted
io_uring/rsrc: send exact nr_segs for fixed buffer
Sending exact nr_segs, avoids bio split check and processing in block layer, which takes around 5%[1] of overall CPU utilization. In our setup, we see overall improvement of IOPS from 7.15M to 7.65M [2] and 5% less CPU utilization. [1] 3.52% io_uring [kernel.kallsyms] [k] bio_split_rw_at 1.42% io_uring [kernel.kallsyms] [k] bio_split_rw 0.62% io_uring [kernel.kallsyms] [k] bio_submit_split [2] sudo taskset -c 0,1 ./t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4 /dev/nvme0n1 /dev/nvme1n1 Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> [Pavel: fixed for kbuf, rebased and reworked on top of cleanups] Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/7a1a49a8d053bd617c244291d63dbfbc07afde36.1744882081.git.asml.silence@gmail.com [axboe: fold in fix factoring in buf reg offset] Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 59852eb commit 80c7378

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

io_uring/rsrc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10371037
u64 buf_addr, size_t len)
10381038
{
10391039
const struct bio_vec *bvec;
1040+
size_t folio_mask;
10401041
unsigned nr_segs;
10411042
size_t offset;
10421043
int ret;
@@ -1067,6 +1068,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10671068
* 2) all bvecs are the same in size, except potentially the
10681069
* first and last bvec
10691070
*/
1071+
folio_mask = (1UL << imu->folio_shift) - 1;
10701072
bvec = imu->bvec;
10711073
if (offset >= bvec->bv_len) {
10721074
unsigned long seg_skip;
@@ -1075,10 +1077,9 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10751077
offset -= bvec->bv_len;
10761078
seg_skip = 1 + (offset >> imu->folio_shift);
10771079
bvec += seg_skip;
1078-
offset &= (1UL << imu->folio_shift) - 1;
1080+
offset &= folio_mask;
10791081
}
1080-
1081-
nr_segs = imu->nr_bvecs - (bvec - imu->bvec);
1082+
nr_segs = (offset + len + bvec->bv_offset + folio_mask) >> imu->folio_shift;
10821083
iov_iter_bvec(iter, ddir, bvec, nr_segs, len);
10831084
iter->iov_offset = offset;
10841085
return 0;

0 commit comments

Comments
 (0)