iov_iter: optimise bvec iov_iter_advance()
iov_iter_advance() is heavily used, but implemented through generic means. For bvecs there is a specifically crafted function for that, so use bvec_iter_advance() instead, it's faster and slimmer. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> (cherry picked from commit 54c8195b4ebe10af66b49ab9c809bc16939555fc) (cherry picked from commit 8cac76228025fb022b1bb15e100efae8acde0425) (cherry picked from commit c8b0dff6b5ac38ff23605bdae1c5bf62766d0fa3) (cherry picked from commit 5bbff4ddbd3f87ddb409753269fa933109a99a7f) (cherry picked from commit 689d9157a0b58f95cb2641a17226b023a1fb226a) (cherry picked from commit 0df724cafe05ae311556249c7df0c2cd00e05007) (cherry picked from commit ba5d942df07c03782ab2aa2b2dd1f7b96b3b5c52)
This commit is contained in:
parent
b93af2c415
commit
f6172ea41b
1 changed files with 19 additions and 0 deletions
|
@ -1060,6 +1060,21 @@ static void pipe_advance(struct iov_iter *i, size_t size)
|
|||
pipe_truncate(i);
|
||||
}
|
||||
|
||||
static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
|
||||
{
|
||||
struct bvec_iter bi;
|
||||
|
||||
bi.bi_size = i->count;
|
||||
bi.bi_bvec_done = i->iov_offset;
|
||||
bi.bi_idx = 0;
|
||||
bvec_iter_advance(i->bvec, &bi, size);
|
||||
|
||||
i->bvec += bi.bi_idx;
|
||||
i->nr_segs -= bi.bi_idx;
|
||||
i->count = bi.bi_size;
|
||||
i->iov_offset = bi.bi_bvec_done;
|
||||
}
|
||||
|
||||
void iov_iter_advance(struct iov_iter *i, size_t size)
|
||||
{
|
||||
if (unlikely(iov_iter_is_pipe(i))) {
|
||||
|
@ -1070,6 +1085,10 @@ void iov_iter_advance(struct iov_iter *i, size_t size)
|
|||
i->count -= size;
|
||||
return;
|
||||
}
|
||||
if (iov_iter_is_bvec(i)) {
|
||||
iov_iter_bvec_advance(i, size);
|
||||
return;
|
||||
}
|
||||
iterate_and_advance(i, size, v, 0, 0, 0)
|
||||
}
|
||||
EXPORT_SYMBOL(iov_iter_advance);
|
||||
|
|
Loading…
Reference in a new issue