From: Andrew Morton <akpm@linux-foundation.org>
To: Ridong <ridong.chen@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Lorenzo Stoakes <ljs@kernel.org>,
Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Zhongkun He <hezhongkun.hzk@bytedance.com>,
Muchun Song <muchun.song@linux.dev>,
Davidlohr Bueso <dave@stgolabs.net>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH -v4 0/4] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim
Date: Thu, 23 Jul 2026 22:37:04 -0700 [thread overview]
Message-ID: <20260723223704.b030220f6ca120c53c2f68d7@linux-foundation.org> (raw)
In-Reply-To: <20260724033435.2573323-1-ridong.chen@linux.dev>
On Fri, 24 Jul 2026 11:34:31 +0800 Ridong <ridong.chen@linux.dev> wrote:
> Fixes and one cleanup.
>
> Patch 1 fixes "swappiness=max": the anon-only test in get_scan_count()
> sat after the "cannot reclaim anon" check, so when no anon was
> reclaimable the request fell back to SCAN_FILE and evicted page cache
> instead.
>
> Patch 2 fixes reclaim_store() collapsing every error into -EAGAIN, so
> callers can no longer tell an invalid argument from a busy interface;
> propagate the real error code, matching the memcg path.
>
> Patch 3 drops the now-unused gfp_mask parameter from __node_reclaim().
>
> Patch 4 fixes the same "swappiness=max" issue for MGLRU.
Thanks, I've updated mm.git's mm-unstable branch to this version.
Sashiko said one thing, but you've examined this before. Hopefully
MGLRU maintainers will consider your suggestion in
https://lore.kernel.org/8336e48a-ab3a-4db9-a7f9-5bb6af2b22c3@linux.dev
https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev
> v3 -> v4:
> - Patch 4: Update comments and commit message.
> - Patch 4: Adopted Sashiko's suggestion to use WARN_ON_ONCE.
Here's how v4 altered mm.git:
mm/vmscan.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
--- a/mm/vmscan.c~b
+++ a/mm/vmscan.c
@@ -2492,7 +2492,13 @@ static void get_scan_count(struct lruvec
enum scan_balance scan_balance;
enum lru_list lru;
- /* Proactive reclaim initiated by userspace for anonymous memory only */
+ /*
+ * Proactive reclaim initiated by userspace for anonymous memory only.
+ * SWAPPINESS_ANON_ONLY is set only on the proactive reclaim path, so
+ * warn if it shows up elsewhere. When anon cannot be reclaimed (e.g.
+ * no swap), bail out instead of falling back to evicting file pages,
+ * which would violate the anon-only semantics.
+ */
if (swappiness == SWAPPINESS_ANON_ONLY) {
WARN_ON_ONCE(!sc->proactive);
if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) {
@@ -2693,6 +2699,10 @@ static int get_swappiness(struct lruvec
{
struct mem_cgroup *memcg = lruvec_memcg(lruvec);
struct pglist_data *pgdat = lruvec_pgdat(lruvec);
+ int swappiness = sc_swappiness(sc, memcg);
+
+ if (swappiness == SWAPPINESS_ANON_ONLY)
+ return swappiness;
if (!sc->may_swap)
return 0;
@@ -2701,7 +2711,7 @@ static int get_swappiness(struct lruvec
mem_cgroup_get_nr_swap_pages(memcg) < MIN_LRU_BATCH)
return 0;
- return sc_swappiness(sc, memcg);
+ return swappiness;
}
static int get_nr_gens(struct lruvec *lruvec, int type)
@@ -4903,6 +4913,20 @@ static long get_nr_to_scan(struct lruvec
struct mem_cgroup *memcg, int swappiness)
{
unsigned long nr_to_scan, evictable;
+ struct pglist_data *pgdat = lruvec_pgdat(lruvec);
+
+ /*
+ * Proactive reclaim initiated by userspace for anonymous memory only.
+ * SWAPPINESS_ANON_ONLY is set only on the proactive reclaim path, so
+ * warn if it shows up elsewhere. When anon cannot be reclaimed (e.g.
+ * no swap), return 0 to skip the scan entirely, avoiding useless scan
+ * work when there is nothing eligible to reclaim.
+ */
+ if (swappiness == SWAPPINESS_ANON_ONLY) {
+ WARN_ON_ONCE(!sc->proactive);
+ if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc))
+ return 0;
+ }
evictable = lruvec_evictable_size(lruvec, swappiness);
_
prev parent reply other threads:[~2026-07-24 5:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 3:34 [PATCH -v4 0/4] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
2026-07-24 3:34 ` [PATCH -v4 1/4] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-24 3:34 ` [PATCH -v4 2/4] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
2026-07-24 3:34 ` [PATCH -v4 3/4] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
2026-07-24 3:34 ` [PATCH -v4 4/4] mm/mglru: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-24 7:18 ` Kairui Song
2026-07-24 5:37 ` Andrew Morton [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=20260723223704.b030220f6ca120c53c2f68d7@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=chenridong@xiaomi.com \
--cc=dave@stgolabs.net \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hezhongkun.hzk@bytedance.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=ridong.chen@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu@google.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