Re: [PATCH v7 04/11] readahead: allocate folios with mapping_min_order in readahead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 14, 2024 at 09:26:02AM +0000, Pankaj Raghav (Samsung) wrote:
> > Hm, but we don't have a reference on this folio.  So this isn't safe.
> 
> That is why I added a check for mapping after read_pages(). You are
> right, we can make it better.

That's not enoughh.

> > > +			if (mapping != folio->mapping)
> > > +				nr_pages = min_nrpages;
> > > +
> > > +			VM_BUG_ON_FOLIO(nr_pages < min_nrpages, folio);
> > > +			ractl->_index += nr_pages;
> > 
> > Why not just:
> > 			ractl->_index += min_nrpages;
> 
> Then we will only move min_nrpages even if the folio we found had a
> bigger order. Hannes patches (first patch) made sure we move the
> ractl->index by folio_nr_pages instead of 1 and making this change will
> defeat the purpose because without mapping order set, min_nrpages will
> be 1.

Hannes' patch is wrong.  It's not safe to call folio_nr_pages() unless
you have a reference to the folio.

> @@ -266,10 +266,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>                          * alignment constraint in the page cache.
>                          *
>                          */
> -                       if (mapping != folio->mapping)
> -                               nr_pages = min_nrpages;
> +                       nr_pages = max(folio_nr_pages(folio), (long)min_nrpages);

No.

> Now we will still move respecting the min order constraint but if we had
> a bigger folio and we do have a reference, then we move folio_nr_pages.

You don't have a reference, so it's never safe.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux