Re: [PATCH v7 00/15] mm/mglru: improve reclaim loop and dirty folio handling
From: Andrew Morton
Date: Mon Apr 27 2026 - 14:25:31 EST
On Tue, 28 Apr 2026 02:06:51 +0800 Kairui Song via B4 Relay <devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> This series cleans up and slightly improves MGLRU's reclaim loop and
> dirty writeback handling. As a result, we can see an up to ~30% increase
> in some workloads like MongoDB with YCSB and a huge decrease in file
> refault, no swap involved. Other common benchmarks have no regression,
> and LOC is reduced, with less unexpected OOM, too.
Thanks, I've updated mm.git's mm-new branch to this version.
> Changes in v7:
> - Fix swappiness not being effective with a standalone fix patch
> from Barry Song. It's OK to be a standalone fix since that is not a
> major bug but an unexpected behavior change, and shouldn't effect any
> bisecting. I slightly adjusted the commit message as the subjcect is too
> long and getting truncated for mail:
> https://lore.kernel.org/linux-mm/20260425205759.1701-1-baohua@xxxxxxxxxx/
> - Remove the min limit for calculating nr_to_scan:
> https://lore.kernel.org/linux-mm/aet1hd9DfRH4aSOO@KASONG-MC4/
> Instead just revert to V1:
> https://sashiko.dev/#/message/20260318-mglru-reclaim-v1-3-2c46f9eb0508%40tencent.com
> Everyone was fine with that, the min limit in later version was
> introduced to cover sashiko's review on V1, but now think again, that's
> actually not a bug and instead could be beneficial. This min
> check doesn't always make sense and there isn't any practical issue observed.
> - Retest still looking very good in every case.
Here's how v7 altered mm.git. (Looks small - did I mess this up?)
--- a/mm/vmscan.c~b
+++ a/mm/vmscan.c
@@ -4788,8 +4788,13 @@ static int isolate_folios(unsigned long
*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;
@@ -4909,18 +4914,14 @@ static long get_nr_to_scan(struct lruvec
unsigned long nr_to_scan, evictable;
evictable = lruvec_evictable_size(lruvec, swappiness);
- nr_to_scan = evictable;
/* try to scrape all its memory if this memcg was deleted */
if (!mem_cgroup_online(memcg))
- return nr_to_scan;
+ return evictable;
- nr_to_scan = apply_proportional_protection(memcg, sc, nr_to_scan);
+ nr_to_scan = apply_proportional_protection(memcg, sc, evictable);
nr_to_scan >>= sc->priority;
- if (!nr_to_scan && sc->priority < DEF_PRIORITY)
- nr_to_scan = min(evictable, SWAP_CLUSTER_MAX);
-
return nr_to_scan;
}
_