All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>,
	Michal Hocko <mhocko@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Ridong Chen <ridong.chen@linux.dev>,
	Ridong Chen <chenridong@xiaomi.com>
Subject: [RFC PATCH 4/4] mm/vmscan: do not skip node reclaim when only anon is reclaimable
Date: Fri, 21 Aug 2026 16:17:41 +0800	[thread overview]
Message-ID: <20260821081741.1340277-5-ridong.chen@linux.dev> (raw)
In-Reply-To: <20260821081741.1340277-1-ridong.chen@linux.dev>

From: Ridong Chen <chenridong@xiaomi.com>

node_reclaim() bailed out with "return 0" whenever both unmapped page
cache and reclaimable slab were at or below their limits:

	if (node_pagecache_reclaimable(pgdat) <= pgdat->min_unmapped_pages &&
	    node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B) <=
	    pgdat->min_slab_pages)
		return 0;

But min_unmapped_pages and min_slab_pages only describe file and slab;
they say nothing about anonymous memory, which node reclaim is otherwise
happy to reclaim (may_swap is set, swappiness applies).  So a node with
little page cache and slab but plenty of reclaimable anon was skipped
entirely, even though there was anon to free.

Require in addition that anon cannot be reclaimed before bailing out, so
the early return only triggers when none of the three types has anything
to reclaim.  When anon is reclaimable the per-type flags leave file and
slab alone, so shrink_node reclaims anon only; checking
can_reclaim_anon_pages() here also avoids entering reclaim just to scan
without freeing anything when swap and demotion are both unavailable.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
---
 mm/vmscan.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5a3f67b3ba32..8c706807da44 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7945,18 +7945,14 @@ unsigned long node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned i
 	};
 
 	/*
-	 * Node reclaim reclaims unmapped file backed pages and
-	 * slab pages if we are over the defined limits.
-	 *
-	 * A small portion of unmapped file backed pages is needed for
-	 * file I/O otherwise pages read by file I/O will be immediately
-	 * thrown out if the node is overallocated. So we do not reclaim
-	 * if less than a specified percentage of the node is used by
-	 * unmapped file backed pages.
+	 * min_unmapped_pages and min_slab_pages only gate file and slab.
+	 * Bail out only when both are under their limits and anon cannot
+	 * be reclaimed either, so we do not skip reclaimable anon.
 	 */
 	if (node_pagecache_reclaimable(pgdat) <= pgdat->min_unmapped_pages &&
 	    node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B) <=
-	    pgdat->min_slab_pages)
+	    pgdat->min_slab_pages &&
+	    !can_reclaim_anon_pages(NULL, pgdat->node_id, &sc))
 		return 0;
 
 	/*
-- 
2.34.1



  parent reply	other threads:[~2026-08-21  8:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  8:17 [RFC PATCH 0/4] mm/vmscan: honour node reclaim limits per type Ridong Chen
2026-08-21  8:17 ` [RFC PATCH 1/4] mm/vmscan: only reclaim slab in node reclaim when over min_slab_pages Ridong Chen
2026-08-21  8:17 ` [RFC PATCH 2/4] mm/vmscan: only reclaim file pages in node reclaim when over min_unmapped_pages Ridong Chen
2026-08-21  8:17 ` [RFC PATCH 3/4] mm/vmscan: drop the combined limit gate in __node_reclaim() Ridong Chen
2026-08-21 12:49   ` Johannes Weiner
2026-08-21  8:17 ` Ridong Chen [this message]
2026-08-21  8:31 ` [RFC PATCH 0/4] mm/vmscan: honour node reclaim limits per type Michal Hocko
2026-08-21  8:58   ` Lorenzo Stoakes (ARM)
2026-08-21  9:21     ` Michal Hocko
2026-08-21 11:16       ` Lorenzo Stoakes (ARM)
2026-08-21 11:26         ` Michal Hocko
2026-08-21 13:43           ` Lorenzo Stoakes (ARM)
2026-08-21  9:07   ` Ridong Chen
2026-08-21  9:24     ` Michal Hocko
2026-08-21 10:52       ` Ridong Chen
2026-08-21 11:02         ` Michal Hocko
2026-08-21 11:10           ` Ridong Chen
2026-08-21 11:20             ` Michal Hocko

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=20260821081741.1340277-5-ridong.chen@linux.dev \
    --to=ridong.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.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 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.