All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: baoquan.he@linux.dev
Cc: akpm@linux-foundation.org, baohua@kernel.org,
	baolin.wang@linux.alibaba.com, hannes@cmpxchg.org,
	hebaoquan@kylinos.cn, kasong@tencent.com, linux-mm@kvack.org,
	mhocko@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev
Subject: Re: [PATCH 2/4] mm/mglru: rename positive_ctrl_err() to should_reclaim()
Date: Wed,  2 Dec 2026 17:59:57 +0800	[thread overview]
Message-ID: <20261202095957.52379-1-baohua@kernel.org> (raw)
In-Reply-To: <20261202061720.284064-3-baoquan.he@linux.dev>

On Wed, Dec 2, 2026 at 2:17 PM Baoquan He <baoquan.he@linux.dev> wrote:
>
> From: Baoquan He <hebaoquan@kylinos.cn>
>
> positive_ctrl_err() is named after control-theory jargon, which
> obscures what the function actually asks: whether the candidate position
> (pv) is worth reclaiming, i.e. it has a limited number of refaults or a
> lower refaulted/total than the current position (sp).
>
> Rename it to should_reclaim() so the reclaim decision is self-evident at
> its call site.

Yes, I agree we should definitely do something here. But simply
renaming the function to should_reclaim() doesn't seem sufficient.
Perhaps we could make things much clearer by doing something like
this?

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 443ee5d30531..65a0ae024524 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3483,7 +3483,7 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long seq)
  * 1. The D term may discount the other two terms over time so that long-lived
  *    generations can resist stale information.
  */
-struct ctrl_pos {
+struct refault_stats {
 	unsigned long refaulted;
 	unsigned long total;
 	int gain;
@@ -3492,8 +3492,8 @@ struct ctrl_pos {
 /*
  * __noipa works around gcc-16 warning for uninitialized use of pos->refaulted
  */
-static void __noipa read_ctrl_pos(struct lruvec *lruvec, int type, int tier_min,
-				  int tier_max, int gain, struct ctrl_pos *pos)
+static void __noipa read_refault_stats(struct lruvec *lruvec, int type, int tier_min,
+				  int tier_max, int gain, struct refault_stats *pos)
 {
 	int i;
 	struct lru_gen_folio *lrugen = &lruvec->lrugen;
@@ -3511,7 +3511,7 @@ static void __noipa read_ctrl_pos(struct lruvec *lruvec, int type, int tier_min,
 	}
 }
 
-static void reset_ctrl_pos(struct lruvec *lruvec, int type, bool carryover)
+static void reset_refault_stats(struct lruvec *lruvec, int type, bool carryover)
 {
 	int hist, tier;
 	struct lru_gen_folio *lrugen = &lruvec->lrugen;
@@ -3547,8 +3547,10 @@ static void reset_ctrl_pos(struct lruvec *lruvec, int type, bool carryover)
 	}
 }
 
-static bool positive_ctrl_err(struct ctrl_pos *sp, struct ctrl_pos *pv)
+static bool can_reclaim_tier(struct refault_stats *base, struct refault_stats *cand)
 {
+	struct refault_stats *sp = base, *pv = cand;
+
 	/*
 	 * Return true if the PV has a limited number of refaults or a lower
 	 * refaulted/total than the SP.
@@ -4288,7 +4290,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness)
 			return false;
 	}
 done:
-	reset_ctrl_pos(lruvec, type, true);
+	reset_refault_stats(lruvec, type, true);
 	WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1);
 
 	return true;
@@ -4354,7 +4356,7 @@ static void try_to_inc_min_seq(struct lruvec *lruvec, int swappiness)
 		if (min_seq[type] <= lrugen->min_seq[type])
 			continue;
 
-		reset_ctrl_pos(lruvec, type, true);
+		reset_refault_stats(lruvec, type, true);
 		WRITE_ONCE(lrugen->min_seq[type], min_seq[type]);
 	}
 }
@@ -4389,7 +4391,7 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, int swappiness
 	}
 
 	for (type = 0; type < ANON_AND_FILE; type++)
-		reset_ctrl_pos(lruvec, type, false);
+		reset_refault_stats(lruvec, type, false);
 
 	next = lru_gen_from_seq(lrugen->max_seq + 1);
 	WRITE_ONCE(lrugen->timestamps[next], jiffies);
@@ -5193,7 +5195,7 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
 static int get_tier_idx(struct lruvec *lruvec, int type)
 {
 	int tier;
-	struct ctrl_pos sp, pv;
+	struct refault_stats base, cand;
 
 	/*
 	 * To leave a margin for fluctuations, use a larger gain factor (1:2).
@@ -5202,9 +5204,9 @@ static int get_tier_idx(struct lruvec *lruvec, int type)
 	 * protects the tiers above it.
 	 */
 	for (tier = LRU_TIER_MIN + 1; tier <= LRU_TIER_MAX; tier++) {
-		read_ctrl_pos(lruvec, type, LRU_TIER_MIN, tier - 1, 1, &sp);
-		read_ctrl_pos(lruvec, type, tier, tier, 2, &pv);
-		if (!positive_ctrl_err(&sp, &pv))
+		read_refault_stats(lruvec, type, LRU_TIER_MIN, tier - 1, 1, &base);
+		read_refault_stats(lruvec, type, tier, tier, 2, &cand);
+		if (!can_reclaim_tier(&base, &cand))
 			break;
 	}
 


  reply	other threads:[~2026-12-02 10:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  6:17 [PATCH 0/4] mm/mglru: cleanup series and a small correctness Baoquan He
2026-12-02  6:17 ` [PATCH 1/4] mm/mglru: use a common helper to check evictable type Baoquan He
2026-12-02  6:41   ` Barry Song
2026-12-02  8:43     ` Baoquan He
2026-12-02  6:17 ` [PATCH 2/4] mm/mglru: rename positive_ctrl_err() to should_reclaim() Baoquan He
2026-12-02  9:59   ` Barry Song (Xiaomi) [this message]
2026-12-02  6:17 ` [PATCH 3/4] mm/mglru: split reset_ctrl_pos() into _update and _reset Baoquan He
2026-12-02 10:12   ` Barry Song
2026-12-02  6:20 ` [PATCH 4/4] mm/mglru: stop counting isolation races as PGSCAN_SKIP in scan_folios() Baoquan He
2026-12-02  9:22   ` Barry Song

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=20261202095957.52379-1-baohua@kernel.org \
    --to=baohua@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=hebaoquan@kylinos.cn \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=shakeel.butt@linux.dev \
    /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.