On Tue, Dec 15, 2020 at 12:20:25AM +0000, Pavel Begunkov wrote: > The block layer spends quite a while in blkdev_direct_IO() to copy and > initialise bio's bvec. However, if we've already got a bvec in the input > iterator it might be reused in some cases, i.e. when new > ITER_BVEC_FLAG_FIXED flag is set. Simple tests show considerable > performance boost, and it also reduces memory footprint. > > Suggested-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> > --- > Documentation/filesystems/porting.rst | 9 ++++ > block/bio.c | 64 +++++++++++---------------- > include/linux/bio.h | 3 ++ > 3 files changed, 38 insertions(+), 38 deletions(-) This doesn't touch iomap code, so the title of the patch seems wrong... > +For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but > +uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and > +page references stay until I/O has completed, i.e. until ->ki_complete() has > +been called or returned with non -EIOCBQUEUED code. This is hard to follow. Perhaps: bio_iov_iter_get_pages() uses the bvecs provided for bvec based iterators rather than copying them. Hence anyone issuing kiocb based IO needs to ensure the bvecs and pages stay referenced until the submitted I/O is completed by a call to ->ki_complete() or returns with an error other than -EIOCBQUEUED. > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 2a9f3f0bbe0a..337f4280b639 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -444,6 +444,9 @@ static inline void bio_wouldblock_error(struct bio *bio) > > static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs) > { > + /* reuse iter->bvec */ > + if (iov_iter_is_bvec(iter)) > + return 0; > return iov_iter_npages(iter, max_segs); Ah, I'm a blind idiot... :/ Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx