linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>,
	Zhaoyang Huang <huangzhaoyang@gmail.com>, <steve.kang@unisoc.com>
Subject: [PATCH] mm: bail out when meet the goal of proactive memcg reclaim
Date: Wed, 21 Jan 2026 17:06:20 +0800	[thread overview]
Message-ID: <20260121090620.559242-1-zhaoyang.huang@unisoc.com> (raw)

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

The proactive memcg reclaim defines the specific target mem cgroup
as well as a certain number of memories, which is different to
the kswapd and direct reclaim that need to keep the fairness among
cgroups. This commit would like to introduce a criteria to have
proactive reclaim bail out when target mem cgroup could meet the goal
via its own lruvec, which means the reclaim would also go through the
whole tree if the iter start on the desendants.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/vmscan.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 670fe9fae5ba..5dcca4559b18 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -6028,8 +6028,15 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc)
 				   sc->nr_scanned - scanned,
 				   sc->nr_reclaimed - reclaimed);
 
-		/* If partial walks are allowed, bail once goal is reached */
-		if (partial && sc->nr_reclaimed >= sc->nr_to_reclaim) {
+		/* If partial walks are allowed, or proactive reclaim where
+		 * the target memcg is clearly defined that could let us ignore
+		 * the fairness thing, bail once goal is reached.
+		 * note: for proactive reclaim, the criteria make sense only
+		 * when target_memcg has both of descendant groups and folios
+		 * charged. Other wise, walk the whole tree under target_memcg.
+		 */
+		if ((partial || (sc->proactive && target_memcg == memcg)) &&
+			       sc->nr_reclaimed >= sc->nr_to_reclaim) {
 			mem_cgroup_iter_break(target_memcg, memcg);
 			break;
 		}
-- 
2.25.1



             reply	other threads:[~2026-01-21  9:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21  9:06 zhaoyang.huang [this message]
2026-01-21 14:38 ` Michal Hocko
2026-01-21 15:54 ` Joshua Hahn
2026-01-22  2:43   ` Zhaoyang Huang

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=20260121090620.559242-1-zhaoyang.huang@unisoc.com \
    --to=zhaoyang.huang@unisoc.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=huangzhaoyang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=steve.kang@unisoc.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