From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: ryncsn@gmail.com
Cc: akpm@linux-foundation.org, axelrasmussen@google.com,
baohua@kernel.org, baolin.wang@linux.alibaba.com,
chenridong@huaweicloud.com, chrisl@kernel.org, david@kernel.org,
hannes@cmpxchg.org, kaleshsingh@google.com, laoar.shao@gmail.com,
lenohou@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, ljs@kernel.org, mhocko@kernel.org,
qi.zheng@linux.dev, shakeel.butt@linux.dev, stevensd@google.com,
surenb@google.com, vernon2gm@gmail.com, wangzicheng@honor.com,
weixugc@google.com, yuanchu@google.com, yuzhao@google.com,
zhengqi.arch@bytedance.com
Subject: Re: [PATCH v6 00/14] mm/mglru: improve reclaim loop and dirty folio handling
Date: Sun, 26 Apr 2026 04:57:59 +0800 [thread overview]
Message-ID: <20260425205759.1701-1-baohua@kernel.org> (raw)
In-Reply-To: <CAMgjq7DM6Sd5EYx=PLtYHBYk6gAPFupYg2a7nib2KrGBO=HtGw@mail.gmail.com>
On Sat, Apr 25, 2026 at 9:30 PM Kairui Song <ryncsn@gmail.com> wrote:
[...]
>
> I just ran a matrix of for kernels (mainline, mm-new HEAD, before this
> series, after this series) X 3 different memcg configs (-j96 3G, -j48
> 2G, -j24 1G), and none of these showed any regression but all
> improvement. That's really odd.
>
> One possibility is that I removed the:
>
> if (evictable_min_seq(lrugen->min_seq, swappiness) + MIN_NR_GENS >
> lrugen->max_seq)
> scanned = 0;
>
> Which will make the reclaim loop go further and trigger aging.
> Previously if reclaim drained the LRU's cold gens, it may go reclaim
> slab instead. So idle inodes will be dropped with the mapping and
> reclaim more file, and we won't see any refault data from that since
> the mapping itself is gone. Sys will be lower too, as IO isn't counted
> as sys. Checking your data, despite sys is higher, real is acutually
> lower, which matches my guess.
>
> Will the following patch help? I'm not sure if this is the problem,
> but this added back that early abort, personally I don't think this
> really makes much sense as it's more like a workaround for other
> issues, but if that helps we might better keep it.
Hi Kairui, after five hours of sleep I’m feeling much more
refreshed and should have identified the issue. I think the
problem will be clear once you look at the patch below.
Feel free to include it in the new version if you find it
helpful.
From e3a0b50dc53a3a5f2ef1adfb73111336e3c2d08b Mon Sep 17 00:00:00 2001
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
Date: Sun, 26 Apr 2026 08:34:21 +1200
Subject: [PATCH] mm/mglru: Avoid falling back to another type when
scan_folios() leaves no remaining pages
While remaining reaches 0 in scan_folios(), we quickly fall back
to the other type in isolate_folios(). This is incorrect, as the
current type may still have sufficient folios. Falling back can
undermine the positive_ctrl_err() result from get_type_to_scan(),
which is derived from swappiness.
A simple fix is to continue scanning this type for another round.
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
mm/vmscan.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index ef45f3a4aa38..169fbbe17c7b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4788,8 +4788,13 @@ static int isolate_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
*isolate_scanned = scanned;
break;
}
-
- type = !type;
+ /*
+ * If scanned > 0 and isolated == 0, avoid falling back to the
+ * other type, as this type remains sufficient. Falling back
+ * too readily can disrupt the positive_ctrl_err() bias.
+ */
+ if (!scanned)
+ type = !type;
}
return total_scanned;
--
2.34.1
Thanks
Barry
next prev parent reply other threads:[~2026-04-25 20:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 17:43 [PATCH v6 00/14] mm/mglru: improve reclaim loop and dirty folio handling Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 01/14] mm/mglru: consolidate common code for retrieving evictable size Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 02/14] mm/mglru: rename variables related to aging and rotation Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 03/14] mm/mglru: relocate the LRU scan batch limit to callers Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 04/14] mm/mglru: restructure the reclaim loop Kairui Song via B4 Relay
2026-04-24 17:04 ` Kairui Song
2026-04-23 17:43 ` [PATCH v6 05/14] mm/mglru: scan and count the exact number of folios Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 06/14] mm/mglru: use a smaller batch for reclaim Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 07/14] mm/mglru: don't abort scan immediately right after aging Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 08/14] mm/mglru: remove redundant swap constrained check upon isolation Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 09/14] mm/mglru: use the common routine for dirty/writeback reactivation Kairui Song via B4 Relay
2026-04-24 19:05 ` Kairui Song
2026-04-23 17:43 ` [PATCH v6 10/14] mm/mglru: simplify and improve dirty writeback handling Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 11/14] mm/mglru: remove no longer used reclaim argument for folio protection Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 12/14] mm/vmscan: remove sc->file_taken Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 13/14] mm/vmscan: remove sc->unqueued_dirty Kairui Song via B4 Relay
2026-04-23 17:43 ` [PATCH v6 14/14] mm/vmscan: unify writeback reclaim statistic and throttling Kairui Song via B4 Relay
2026-04-23 18:14 ` [PATCH v6 00/14] mm/mglru: improve reclaim loop and dirty folio handling Andrew Morton
2026-04-24 10:32 ` Barry Song
2026-04-24 11:58 ` Barry Song
2026-04-24 12:55 ` Kairui Song
2026-04-25 12:18 ` Barry Song
2026-04-25 13:29 ` Kairui Song
2026-04-25 20:57 ` Barry Song (Xiaomi) [this message]
2026-04-26 6:59 ` Kairui Song
2026-04-26 8:34 ` Barry Song
2026-04-24 13:36 ` Andrew Morton
2026-04-24 14:16 ` Kairui 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=20260425205759.1701-1-baohua@kernel.org \
--to=baohua@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=chenridong@huaweicloud.com \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kaleshsingh@google.com \
--cc=laoar.shao@gmail.com \
--cc=lenohou@gmail.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=ryncsn@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=stevensd@google.com \
--cc=surenb@google.com \
--cc=vernon2gm@gmail.com \
--cc=wangzicheng@honor.com \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--cc=yuzhao@google.com \
--cc=zhengqi.arch@bytedance.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