Re: [RFC v2 03/14] filemap: use mapping_min_order while allocating folios

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

 



> > +++ b/mm/filemap.c
> > @@ -127,6 +127,7 @@
> >  static void page_cache_delete(struct address_space *mapping,
> >  				   struct folio *folio, void *shadow)
> >  {
> > +	unsigned int min_order = mapping_min_folio_order(mapping);
> >  	XA_STATE(xas, &mapping->i_pages, folio->index);
> >  	long nr = 1;
> >  
> > @@ -135,6 +136,7 @@ static void page_cache_delete(struct address_space *mapping,
> >  	xas_set_order(&xas, folio->index, folio_order(folio));
> >  	nr = folio_nr_pages(folio);
> >  
> > +	VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio);
> >  	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
> 
> If you are only using min_order in the VM_BUG_ON_FOLIO() macro, then
> please just do:
> 
> 	VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_folio_order(mapping),
> 			folio);
> 
> There is no need to clutter up the function with variables that are
> only used in one debug-only check.
> 
Got it. I will fold it in.

> > @@ -1847,6 +1853,10 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> >  		fgf_t fgp_flags, gfp_t gfp)
> >  {
> >  	struct folio *folio;
> > +	unsigned int min_order = mapping_min_folio_order(mapping);
> > +	unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
> > +
> > +	index = round_down(index, min_nrpages);
> 
> 	index = mapping_align_start_index(mapping, index);

I will add this helper. Makes the intent more clear. Thanks.

> 
> The rest of the function only cares about min_order, not
> min_nrpages....
> 
> -Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux