diff options
| author | Baolin Wang <baolin.wang@linux.alibaba.com> | 2026-09-14 19:29:22 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-01 19:12:25 -0700 |
| commit | c542ea74e4b84831f7162b10d80d207ae55ccefd (patch) | |
| tree | d19b52a17036d69fb8be80de039be5db34cae70c /include/linux/errqueue.h | |
| parent | b2ccead9cdae1d0559acb2b9b29292568a2bb4ca (diff) | |
| download | linux-next-c542ea74e4b84831f7162b10d80d207ae55ccefd.tar.gz linux-next-c542ea74e4b84831f7162b10d80d207ae55ccefd.zip | |
mm: mglru: clear the reference counter for rejected folios
As per the comment on LRU_REFS_FLAGS, when accessed folios are promoted to
a new generation, LRU_REFS_FLAGS should be cleared so that the reference
counter can start over.
For folios rejected by shrink_folio_list(), we clear LRU_REFS_FLAGS and
set the PG_active flag when lru_gen_folio_seq() would place them in the
oldest generation. That's fine.
But for rejected folios where lru_gen_folio_seq() returns a generation
other than the oldest one (which can be treated as a promotion), we do not
clear LRU_REFS_FLAGS. This can violate the promotion mechanism. And this
means the rejected folio enters the new generation with stale, inflated
tier bits, which can inflate reference counts and distort eviction
statistics for these rejected folios.
Fix this by clearing LRU_REFS_FLAGS for rejected folios. Of course, I
need to evaluate the impact of the changes, which mainly falls into 3
cases: 1. When lru_gen_folio_seq() returns the oldest generation for
rejected folios, there are no logic changes, and they will be put back
into the 2nd youngest generation. 2. For rejected folios with PG_active
set by shrink_folio_list(), we only clear the LRU_REFS_FLAGS and do not
change the generation. 3. For rejected folios with PG_referenced set,
the original code would put them back into the 2nd oldest generation.
After this patch, we will put them back into the 2nd youngest generation.
I think case 3 is also reasonable, before commmit 6cbdd9726fb5 ("mm/mglru:
use folio_mark_accessed to replace folio_set_active"), a rejected
referenced folio was also put back to the 2nd youngest gen. Meanwhile, I
didn't see any noticeable performance impact on my 32-core Arm machine
when running 'make -j32' to build the kernel inside a 3G-limited memcg
with either zram or NVMe swap.
Link: https://lore.kernel.org/7384df363c12e4acdaa2e0428420cd8eed320ee7.1789384831.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Baoquan He <baoquan.he@linux.dev>
Reviewed-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Diffstat (limited to 'include/linux/errqueue.h')
0 files changed, 0 insertions, 0 deletions
