Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: wangwensheng <wsw9603@163.com>
Cc: vbabka@kernel.org, hannes@cmpxchg.org, surenb@google.com,
	brendan.jackman@linux.dev, ziy@nvidia.com,
	akpm@linux-foundation.org, chrisl@kernel.org, kasong@tencent.com,
	shikemeng@huaweicloud.com, nphamcs@gmail.com,
	baoquan.he@linux.dev, baohua@kernel.org, youngjun.park@lge.com,
	david@kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath
Date: Fri, 4 Dec 2026 10:29:52 +0100	[thread overview]
Message-ID: <axKIEH3vTwapq9Vg@tiehlicka> (raw)
In-Reply-To: <6164d115-448b-4649-80f6-28480b123ac0@163.com>

On Fri 04-12-26 09:42:55, wangwensheng wrote:
> 
> 
> On 12/4/26 01:24, Michal Hocko wrote:
> > On Thu 03-12-26 22:23:06, Wang Wensheng wrote:
> > > It is not uncommon to enter __alloc_pages_slowpath() with both
> > > PF_MEMALLOC and __GFP_NOFAIL set during memory reclaim. The original
> > > warning was placed where an allocation attempt had failed, intended to
> > > alert about a potential silent stall: with PF_MEMALLOC, direct reclaim
> > > cannot be performed, while __GFP_NOFAIL forces the allocation to keep
> > > retrying.
> > > 
> > > Commit 903edea6c53f ("mm: warn about illegal __GFP_NOFAIL usage in
> > > a more appropriate location and manner") moved this warning to the
> > > very start of __alloc_pages_slowpath(), before any allocation attempt.
> > > This causes frequent false positives: PF_MEMALLOC allows allocations
> > > to ignore watermarks, and the fastpath only checks the low watermark,
> > > so the first allocation attempt inside the slowpath is likely to
> > > succeed.
> > 
> > So essentially you are telling that we shouldn't warn if the allocation
> > just manages to succeeds because there are memory reserves available.
> > While the intention of the code is to catch the unsupported GFP_NOFAIL
> > use from the allocation context. See the difference?
> > 
> 
> Am I right to understand that __GFP_NOFAIL must not be used together with
> PF_MEMALLOC? In ext4, however, many memory allocation failures are hard to
> handle gracefully. Meanwhile, PF_MEMALLOC is set within the reclaim path and
> has no direct connection to ext4. This rule would therefore couple these two
> subsystems, which seems difficult to adhere to.

GFP_NOFAIL allocations from the memory reclaim context are simply
broken! There is no way to guanratee any forward progress while being
stuck in the page allocator which is blocking the reclaim. This is a
dead lock scenario. See?

> Besides, it does not make sense to emit warnings when user workloads remain
> unaffected — I believe this should be a common understanding. Hence this
> warning needs to be addressed. Do you have any alternative suggestions for
> this scenario?

Yes, do not require NOFAIL allocation from the memory reclaim path.
Exactly what the warning tells you.

> For additional context: this issue occurs on an embedded system. We have
> very little free memory, the workload is stable with low memory usage
> fluctuation. The same workload ran for a long time without trouble on older
> kernels. On the new kernel, we only hit this warning rather than an OOM.

THis is not about how much memory there really is. This is about a wrong
memory allocation use. If the caller can handle allocation failure
gracefully it shouldn't use NOFAIL in the first place.
-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2026-12-04  9:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:23 [PATCH 0/2] Fix spurious warnings about memory allocation Wang Wensheng
2026-12-03 14:23 ` [PATCH 1/2] mm/swap: Don't warn if swap_cluster_alloc_table() failed Wang Wensheng
2026-12-04  2:32   ` Youngjun Park
2026-12-04  5:06     ` wangwensheng
2026-12-04  8:21   ` Dev Jain
2026-12-03 14:23 ` [PATCH 2/2] mm/page_alloc: Move PF_MEMALLOC warning to nopage tag in the slowpath Wang Wensheng
2026-12-03 17:24   ` Michal Hocko
2026-12-04  1:42     ` wangwensheng
2026-12-04  9:29       ` Michal Hocko [this message]
2026-12-04  9:06   ` Vlastimil Babka (SUSE)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axKIEH3vTwapq9Vg@tiehlicka \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baoquan.he@linux.dev \
    --cc=brendan.jackman@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=wsw9603@163.com \
    --cc=youngjun.park@lge.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox