All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "Gregory Price (Meta)" <gourry@gourry.net>, <linux-mm@kvack.org>,
	"Jiayuan Chen" <jiayuan.chen@shopee.com>
Cc: <linux-kernel@vger.kernel.org>, <kernel-team@meta.com>,
	<akpm@linux-foundation.org>, <vbabka@kernel.org>,
	<surenb@google.com>, <mhocko@suse.com>,
	<brendan.jackman@linux.dev>, <hannes@cmpxchg.org>,
	<flyinrm@gmail.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH] mm/page_alloc: let the highest memory node recover from hopeless state
Date: Mon, 19 Oct 2026 15:51:27 -0400	[thread overview]
Message-ID: <DM92ROTIF1U8.26CQNH7ZPEBG@nvidia.com> (raw)
In-Reply-To: <20261019184850.3427905-1-gourry@gourry.net>

On Mon Oct 19, 2026 at 2:48 PM EDT, Gregory Price (Meta) wrote:
> free_frozen_page_commit() clears a hopeless node's kswapd failures once
> its zone recovers above the high watermark, but only if another memory
> node exists for allocations to fall back to.
>
> The test `next_memory_node(nid) < MAX_NUMNODES` finds only memory nodes
> with a higher id. The highest-numbered memory node therefore never
> recovers on this path, and its kswapd stays disabled until reclaim on
> that node makes progress and balances it, or demotion is re-enabled.
>
> In many cases, direct reclaim many never fully run against a lower
> node (CXL/kmem), and that means its kswapd can end up full disabled
> in rare situations.
>
> To reproduce, fill the highest memory node with bound, non-THP anonymous
> memory and no swap until kswapd gives up, then free it: /proc/zoneinfo
> keeps showing node_unreclaimable 1 for that node. A lower node recovers.
>
> Count the memory nodes instead. Adding first_memory_node != nid to the
> existing test would also work, but a count says directly what the check
> means: some other memory node exists.
>
> Fixes: e7a5f249e6db ("mm: re-enable kswapd when memory pressure subsides or demotion is toggled")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
> ---
>  mm/page_alloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 417c427b196d9..6d4f03faf96ee 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2929,7 +2929,7 @@ static bool free_frozen_page_commit(struct zone *zone,
>  		 * kswapd work again by resetting kswapd_failures.
>  		 */
>  		if (kswapd_test_hopeless(pgdat) &&
> -		    next_memory_node(pgdat->node_id) < MAX_NUMNODES)
> +		    num_node_state(N_MEMORY) > 1)

Why does a runtime behavior, clearing kswapd hopeless state, depend on a
static memory topology (excluding memory hotadd/hotremove in this
context)? There is nothing telling us if a fallback node has available memory.

Just reset it regardless. kswapd can go hopeless later if the node
cannot be reclaimed.

BTW, LLM also points out that kswapd_try_clear_hopeless(), called by
direct reclaim, only clears hopeless when the node is balanced, but that
rarely happens. So hopeless state can stay much longer if there is only
one node. Adding Jiayuna, who added kswapd_try_clear_hopeless(), to gvie
some insight.

>  			kswapd_clear_hopeless(pgdat, KSWAPD_CLEAR_HOPELESS_PCP);
>  	}
>  	return ret;




-- 
Best Regards,
Yan, Zi



  reply	other threads:[~2026-10-19 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 18:48 [PATCH] mm/page_alloc: let the highest memory node recover from hopeless state Gregory Price (Meta)
2026-10-19 19:51 ` Zi Yan [this message]
2026-10-19 20:16   ` Gregory Price
2026-10-19 20:13 ` Johannes Weiner
2026-10-19 20:40   ` Gregory Price
2026-10-20  7:21 ` 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=DM92ROTIF1U8.26CQNH7ZPEBG@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.jackman@linux.dev \
    --cc=flyinrm@gmail.com \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=jiayuan.chen@shopee.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.