Re: [PATCH] proc: Avoid costly high-order page allocations when reading proc files

Michal Hocko
2025-04-03T07:22:50Z

On Wed 02-04-25 21:37:40, Shakeel Butt wrote:
> On Wed, Apr 02, 2025 at 02:24:45PM +0200, Michal Hocko wrote:
> > diff --git a/mm/util.c b/mm/util.c
> > index 60aa40f612b8..8386f6976d7d 100644
> > --- a/mm/util.c
> > +++ b/mm/util.c
> > @@ -601,14 +601,18 @@ static gfp_t kmalloc_gfp_adjust(gfp_t flags, size_t size)
> > * We want to attempt a large physically contiguous block first because
> > * it is less likely to fragment multiple larger blocks and therefore
> > * contribute to a long term fragmentation less than vmalloc fallback.
> > - * However make sure that larger requests are not too disruptive - no
> > - * OOM killer and no allocation failure warnings as we have a fallback.
> > + * However make sure that larger requests are not too disruptive - i.e.
> > + * do not direct reclaim unless physically continuous memory is preferred
> > + * (__GFP_RETRY_MAYFAIL mode). We still kick in kswapd/kcompactd to start
> > + * working in the background but the allocation itself.
> > */
> > if (size > PAGE_SIZE) {
> > flags |= __GFP_NOWARN;
> >
> > if (!(flags & __GFP_RETRY_MAYFAIL))
> > flags |= __GFP_NORETRY;
> > + else
> > + flags &= ~__GFP_DIRECT_RECLAIM;
>
> I think you wanted the following instead:
>
> if (!(flags & __GFP_RETRY_MAYFAIL))
> flags &= ~__GFP_DIRECT_RECLAIM;

You are absolutely right. Not sure what I was thinking... I will send a
full patch with a changelog to wrap the situation up.

--
Michal Hocko
SUSE Labs