Skip to content

Commit 50169d0

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: separate kbuf offset adjustments
Kernel registered buffers are special because segments are not uniform in size, and we have a bunch of optimisations based on that uniformity for normal buffers. Handle kbuf separately, it'll be cleaner this way. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/4e9e5990b0ab5aee723c0be5cd9b5bcf810375f9.1744882081.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1ac5712 commit 50169d0

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

io_uring/rsrc.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,11 +1048,14 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10481048
if (!(imu->dir & (1 << ddir)))
10491049
return -EFAULT;
10501050

1051-
/*
1052-
* Might not be a start of buffer, set size appropriately
1053-
* and advance us to the beginning.
1054-
*/
10551051
offset = buf_addr - imu->ubuf;
1052+
1053+
if (imu->is_kbuf) {
1054+
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len);
1055+
iov_iter_advance(iter, offset);
1056+
return 0;
1057+
}
1058+
10561059
iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len);
10571060

10581061
/*
@@ -1072,17 +1075,9 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
10721075
* be folio_size aligned.
10731076
*/
10741077
bvec = imu->bvec;
1075-
1076-
/*
1077-
* Kernel buffer bvecs, on the other hand, don't necessarily
1078-
* have the size property of user registered ones, so we have
1079-
* to use the slow iter advance.
1080-
*/
10811078
if (offset < bvec->bv_len) {
10821079
iter->count -= offset;
10831080
iter->iov_offset = offset;
1084-
} else if (imu->is_kbuf) {
1085-
iov_iter_advance(iter, offset);
10861081
} else {
10871082
unsigned long seg_skip;
10881083

0 commit comments

Comments
 (0)