Re: [PATCH v3 17/25] mm: Add __page_cache_alloc_order

From: Matthew Wilcox
Date: Sat Jun 06 2020 - 23:09:07 EST


On Wed, May 06, 2020 at 11:03:06AM -0700, Yang Shi wrote:
> > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> > index 55199cb5bd66..1169e2428dd7 100644
> > --- a/include/linux/pagemap.h
> > +++ b/include/linux/pagemap.h
> > @@ -205,15 +205,33 @@ static inline int page_cache_add_speculative(struct page *page, int count)
> > return __page_cache_add_speculative(page, count);
> > }
> >
> > +static inline gfp_t thp_gfpmask(gfp_t gfp)
> > +{
> > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> > + /* We'd rather allocate smaller pages than stall a page fault */
> > + gfp |= GFP_TRANSHUGE_LIGHT;
>
> This looks not correct. GFP_TRANSHUGE_LIGHT may set GFP_FS, but some
> filesystem may expect GFP_NOFS, i.e. in readahead path.

Apologies, I overlooked this mail.

In one of the prerequisite patches for this patch set (which is now merged
as f2c817bed58d9be2051fad1d18e167e173c0c227), we call memalloc_nofs_save()
in the readahead path. That ensures all allocations will have GFP_NOFS
set by the time the page allocator sees them.

Thanks for checking on this.