Re: [PATCH v2 1/2] iov_iter: optimise iov_iter_npages for bvec

From: Pavel Begunkov
Date: Thu Nov 19 2020 - 20:42:37 EST


On 20/11/2020 01:20, Matthew Wilcox wrote:
> On Thu, Nov 19, 2020 at 11:24:38PM +0000, Pavel Begunkov wrote:
>> The block layer spends quite a while in iov_iter_npages(), but for the
>> bvec case the number of pages is already known and stored in
>> iter->nr_segs, so it can be returned immediately as an optimisation
>
> Er ... no, it doesn't. nr_segs is the number of bvecs. Each bvec can
> store up to 4GB of contiguous physical memory.

Ah, really, missed min() with PAGE_SIZE in bvec_iter_len(), then it's a
stupid statement. Thanks!

Are there many users of that? All these iterators are a huge burden,
just to count one 4KB page in bvec it takes 2% of CPU time for me.

--
Pavel Begunkov