From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, kasong@tencent.com,
qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org,
axelrasmussen@google.com, yuanchu.xie@google.com,
weixugc@google.com, baoquan.he@linux.dev,
baolin.wang@linux.alibaba.com, chenridong@xiaomi.com,
Yu Zhao <yuzhao@google.com>, Bo Zhang <zhangbo56@xiaomi.com>
Subject: [RFC PATCH] mm/mglru: Avoid reclaiming kept folios during retrying missed rotated folios
Date: Sat, 3 Oct 2026 13:42:16 +0800 [thread overview]
Message-ID: <20261003054216.9155-1-baohua@kernel.org> (raw)
Since commit 4d5d14a01e2c ("mm/mglru: rework workingset protection"),
`folio_test_referenced()` was accidentally removed when checking for
missed rotated folios. As a result, kept folios without an active set
could be added to the retry list and eventually reclaimed.
The impact should be very small, as we have the `folio_mapped(folio)`
check before retrying. Kept folios won't have `try_to_unmap()` called,
so this is really only applicable to folios that are unmapped by users
after `folio_referenced()` has been called.
I'm not sure if anyone else has seen any issues with this. Sending an
RFC to check whether it is worth fixing.
Fixes: 4d5d14a01e2c ("mm/mglru: rework workingset protection")
Cc: Yu Zhao <yuzhao@google.com>
Reported-by: Bo Zhang <zhangbo56@xiaomi.com>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
mm/vmscan.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 91295070ca33..6a931b576b7d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -994,8 +994,10 @@ static enum folio_references folio_check_references(struct folio *folio,
return FOLIOREF_KEEP;
if (lru_gen_enabled() && !lru_gen_switching()) {
- if (!referenced_ptes)
+ if (!referenced_ptes) {
+ folio_clear_referenced(folio);
return FOLIOREF_RECLAIM;
+ }
return lru_gen_set_refs(folio, &vma_flags) ? FOLIOREF_ACTIVATE : FOLIOREF_KEEP;
}
@@ -5110,7 +5112,8 @@ static int evict_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
continue;
/* retry folios that may have missed folio_rotate_reclaimable() */
- if (!skip_retry && !folio_test_active(folio) && !folio_mapped(folio) &&
+ if (!skip_retry && !folio_test_active(folio) &&
+ !folio_test_referenced(folio) && !folio_mapped(folio) &&
!folio_test_dirty(folio) && !folio_test_writeback(folio)) {
list_move(&folio->lru, &clean);
continue;
--
2.39.3 (Apple Git-146)
next reply other threads:[~2026-10-03 5:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 5:42 Barry Song (Xiaomi) [this message]
2026-10-08 6:52 ` [RFC PATCH] mm/mglru: Avoid reclaiming kept folios during retrying missed rotated folios Baolin Wang
2026-10-08 11:43 ` Kairui Song
2026-10-08 11:52 ` Kairui Song
2026-10-08 12:23 ` 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=20261003054216.9155-1-baohua@kernel.org \
--to=baohua@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=chenridong@xiaomi.com \
--cc=kasong@tencent.com \
--cc=linux-mm@kvack.org \
--cc=qi.zheng@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu.xie@google.com \
--cc=yuzhao@google.com \
--cc=zhangbo56@xiaomi.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