Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <baoquan.he@linux.dev>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, kasong@tencent.com, baohua@kernel.org,
	qi.zheng@linux.dev, shakeel.butt@linux.dev, baoquan.he@linux.dev,
	baolin.wang@linux.alibaba.com, hannes@cmpxchg.org,
	mhocko@kernel.org, Baoquan He <hebaoquan@kylinos.cn>
Subject: [PATCH 1/4] mm/mglru: use a common helper to check evictable type
Date: Wed,  2 Dec 2026 14:17:15 +0800	[thread overview]
Message-ID: <20261202061720.284064-2-baoquan.he@linux.dev> (raw)
In-Reply-To: <20261202061720.284064-1-baoquan.he@linux.dev>

From: Baoquan He <hebaoquan@kylinos.cn>

inc_min_seq() open-codes the evictable type check that
for_each_evictable_type() already expresses through min_type() and
max_type(). Use a shared is_type_evictable() helper so the two cannot
drift apart, and rename the done label to advance to make it clear that
a skipped rotation still advances min_seq.

No functional change.

Signed-off-by: Baoquan He <hebaoquan@kylinos.cn>
---
 mm/vmscan.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index be89bc2528a9..257305fe1cce 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2785,6 +2785,11 @@ static bool should_clear_pmd_young(void)
 #define min_type(swappiness) (!(swappiness))
 #define max_type(swappiness) ((swappiness) < SWAPPINESS_ANON_ONLY)
 
+static inline bool is_type_evictable(int type, int swappiness)
+{
+	return type >= min_type(swappiness) && type <= max_type(swappiness);
+}
+
 #define evictable_min_seq(min_seq, swappiness)				\
 	min((min_seq)[min_type(swappiness)], (min_seq)[max_type(swappiness)])
 
@@ -3976,13 +3981,9 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness)
 	int new_gen, old_gen = lru_gen_from_seq(lrugen->min_seq[type]);
 	int target_gen = (old_gen + 1) % MAX_NR_GENS;
 
-	/* For file type, skip the check if swappiness is anon only */
-	if (type && (swappiness == SWAPPINESS_ANON_ONLY))
-		goto done;
-
-	/* For anon type, skip the check if swappiness is zero (file only) */
-	if (!type && !swappiness)
-		goto done;
+	/* A type that isn't being reclaimed needs no rotation */
+	if (!is_type_evictable(type, swappiness))
+		goto advance;
 
 	VM_WARN_ON_ONCE(get_nr_gens(lruvec, type) != MAX_NR_GENS);
 	VM_WARN_ON_ONCE(lru_gen_is_active(lruvec, old_gen) !=
@@ -4042,7 +4043,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness)
 		if (!remaining)
 			return false;
 	}
-done:
+advance:
 	reset_ctrl_pos(lruvec, type, true);
 	WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1);
 
-- 
2.52.0



  reply	other threads:[~2026-12-02  6:17 UTC|newest]

Thread overview: 5+ 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 ` Baoquan He [this message]
2026-12-02  6:17 ` [PATCH 2/4] mm/mglru: rename positive_ctrl_err() to should_reclaim() Baoquan He
2026-12-02  6:17 ` [PATCH 3/4] mm/mglru: split reset_ctrl_pos() into _update and _reset Baoquan He
2026-12-02  6:20 ` [PATCH 4/4] mm/mglru: stop counting isolation races as PGSCAN_SKIP in scan_folios() Baoquan He

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=20261202061720.284064-2-baoquan.he@linux.dev \
    --to=baoquan.he@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox