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 4/4] mm/mglru: stop counting isolation races as PGSCAN_SKIP in scan_folios()
Date: Wed,  2 Dec 2026 14:20:40 +0800	[thread overview]
Message-ID: <20261202062040.284330-1-baoquan.he@linux.dev> (raw)
In-Reply-To: <20261202061720.284064-1-baoquan.he@linux.dev>

From: Baoquan He <hebaoquan@kylinos.cn>

scan_folios() counted pages it failed to isolate because of a race
(folio_try_get() or folio_test_clear_lru() failed) and reported them as
PGSCAN_SKIP and nr_skipped.

PGSCAN_SKIP is for pages skipped because they sit in zones above the
reclaim target.  MGLRU only iterates zones at or below that target, so it
never has ineligible-zone pages at all; the only thing that fed
PGSCAN_SKIP here was isolation races, which misrepresents the counter.

Rename skipped_zone to isolate_failed and drop the PGSCAN_SKIP
accounting.  nr_skipped is passed as 0: the field is kept so the event
still lines up with mm_vmscan_lru_isolate, and the races themselves are
transient, the folios go back to the generation list and are retried.

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

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9211ffcdcea9..9894221cbb6d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4867,7 +4867,6 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
 	int sorted = 0;
 	int scanned = 0;
 	int isolated = 0;
-	int skipped = 0;
 	int gen, max_gen;
 	unsigned long seq;
 	unsigned long remaining = nr_to_scan;
@@ -4901,7 +4900,7 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
 	/* Scan eligible zones in descending order. */
 	for (zone_idx = sc->reclaim_idx; zone_idx >= 0; zone_idx--) {
 		LIST_HEAD(moved);
-		int skipped_zone = 0;
+		int isolate_failed = 0;
 		struct zone *zone = &pgdat->node_zones[zone_idx];
 		struct list_head *head = &lrugen->folios[gen][type][zone_idx];
 
@@ -4925,18 +4924,15 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
 				isolated += delta;
 			} else {
 				list_move(&folio->lru, &moved);
-				skipped_zone += delta;
+				isolate_failed += delta;
 			}
 
-			if (!--remaining || max(isolated, skipped_zone) >= MIN_LRU_BATCH)
+			if (!--remaining || max(isolated, isolate_failed) >= MIN_LRU_BATCH)
 				break;
 		}
 
-		if (skipped_zone) {
+		if (isolate_failed)
 			list_splice(&moved, head);
-			__count_zid_vm_events(PGSCAN_SKIP, zone_idx, skipped_zone);
-			skipped += skipped_zone;
-		}
 
 		if (!remaining || isolated >= MIN_LRU_BATCH)
 			break;
@@ -4947,10 +4943,10 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
 	mod_lruvec_state(lruvec, PGREFILL, sorted);
 	mod_lruvec_state(lruvec, PGSCAN_ANON + type, isolated);
 	trace_mm_vmscan_lru_isolate(sc, nr_to_scan,
-				    scanned, skipped, isolated,
+				    scanned, 0, isolated,
 				    type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON);
 	trace_mm_mglru_scan_folios(lruvec, sc, nr_to_scan, scanned, sorted,
-				   skipped, isolated, type, tier);
+				   0, isolated, type, tier);
 
 	*isolatedp = isolated;
 	return scanned;
-- 
2.52.0



      parent reply	other threads:[~2026-12-02  6:20 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 ` [PATCH 1/4] mm/mglru: use a common helper to check evictable type Baoquan He
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 ` Baoquan He [this message]

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=20261202062040.284330-1-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