Re: [PATCH v3 04/11] readahead: rework loop in page_cache_ra_unbounded()
From: Pankaj Raghav (Samsung)
Date: Tue Mar 26 2024 - 04:56:32 EST
On Mon, Mar 25, 2024 at 06:41:01PM +0000, Matthew Wilcox wrote:
> On Wed, Mar 13, 2024 at 06:02:46PM +0100, Pankaj Raghav (Samsung) wrote:
> > @@ -239,8 +239,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> > * not worth getting one just for that.
> > */
> > read_pages(ractl);
> > - ractl->_index++;
> > - i = ractl->_index + ractl->_nr_pages - index - 1;
> > + ractl->_index += folio_nr_pages(folio);
> > + i = ractl->_index + ractl->_nr_pages - index;
> > continue;
> > }
> >
> > @@ -252,13 +252,14 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> > folio_put(folio);
> > read_pages(ractl);
> > ractl->_index++;
> > - i = ractl->_index + ractl->_nr_pages - index - 1;
> > + i = ractl->_index + ractl->_nr_pages - index;
> > continue;
> > }
>
> You changed index++ in the first hunk, but not the second hunk. Is that
> intentional?
The reason I didn't use folio_nr_pages(folio) in the second hunk is
because we have already `put` the folio and it is not valid anymore to
use folio_nr_pages right? Because we increase the ref count in
filemap_alloc() and we put if add fails.
Plus in the second hunk, adding the 0 order folio failed in that index,
so we just move on to the next index. Once we have the min order
support, if adding min order folio failed, we move by min_order.
And your comment on the next patch:
> Hah, you changed this here. Please move into previous patch.
We can't do that either because I am introducing the concept of min
order in the next patch.