iov_iter: don't call into iov_iter_revert() for non-zero bytes iov-misc
authorJens Axboe <axboe@kernel.dk>
Wed, 24 Jan 2024 15:25:30 +0000 (08:25 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 Jan 2024 15:27:52 +0000 (08:27 -0700)
commit757a0f5befe9056c4a174f51d7276f1429c25e16
tree965ac45b8983e7ab2135bf07115e587b3b605d94
parent01548ab553e69615b2d7f9e247524af7c2df984f
iov_iter: don't call into iov_iter_revert() for non-zero bytes

Most callers don't check if there's actually data to revert, so we end
up doing a function call only to return immediately because unroll is
equal to zero.

Add an inline helper that checks if we have bytes to unroll, and only
call into __iov_iter_revert() if that is the case, rather than add
this check in the callers we care about.

This saves 0.30% for me in workload that uses iov iterators intensively.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/uio.h
lib/iov_iter.c