* [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim
@ 2026-07-17 11:32 Ridong
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Ridong @ 2026-07-17 11:32 UTC (permalink / raw)
To: Andrew Morton, Johannes Weiner
Cc: Kairui Song, Qi Zheng, Shakeel Butt, Barry Song, Axel Rasmussen,
Yuanchu Xie, Wei Xu, David Hildenbrand, Michal Hocko,
Lorenzo Stoakes, Zhongkun He, Muchun Song, Davidlohr Bueso,
Roman Gushchin, linux-mm, linux-kernel, Ridong Chen, Ridong Chen
From: Ridong Chen <chenridong@xiaomi.com>
Two 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().
Ridong Chen (3):
mm/vmscan: fix anon-only reclaim evicting file pages when
swappiness=max
mm: vmscan: propagate real error code from per-node proactive reclaim
mm: vmscan: drop unused gfp_mask parameter from __node_reclaim()
mm/vmscan.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max
2026-07-17 11:32 [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
@ 2026-07-17 11:32 ` Ridong
2026-07-17 12:04 ` Johannes Weiner
` (2 more replies)
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
` (2 subsequent siblings)
3 siblings, 3 replies; 14+ messages in thread
From: Ridong @ 2026-07-17 11:32 UTC (permalink / raw)
To: Andrew Morton, Johannes Weiner
Cc: Kairui Song, Qi Zheng, Shakeel Butt, Barry Song, Axel Rasmussen,
Yuanchu Xie, Wei Xu, David Hildenbrand, Michal Hocko,
Lorenzo Stoakes, Zhongkun He, Muchun Song, Davidlohr Bueso,
Roman Gushchin, linux-mm, linux-kernel, Ridong Chen, Ridong Chen
From: Ridong Chen <chenridong@xiaomi.com>
As Qi mentioned [1], when swappiness=max (SWAPPINESS_ANON_ONLY) is set,
the reclaim logic is expected to reclaim anonymous pages exclusively.
However, due to the current ordering of checks in get_scan_count(),
file pages may still be evicted if can_reclaim_anon_pages() returns
false, which contradicts the semantics of SWAPPINESS_ANON_ONLY.
Reproducer in a cgroup holding 64M of file cache, with no swap configured:
Before (file cache is wrongly evicted):
# cat memory.stat
anon 196608
file 67178496
pgscan_proactive 0
# echo "64M swappiness=max" > memory.reclaim
# cat memory.stat
anon 208896
file 4096 <- page cache evicted
pgsteal_proactive 16400
pgscan_proactive 16400
After (file cache is left intact):
# cat memory.stat
anon 200704
file 67178496
pgscan_proactive 0
# echo "64M swappiness=max" > memory.reclaim
-bash: echo: write error: Resource temporarily unavailable
# cat memory.stat
anon 208896
file 67178496 <- page cache untouched
pgsteal_proactive 0
pgscan_proactive 0
Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no
anonymous pages are reclaimable, before falling back to file reclaim.
[1] https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux.dev/
Fixes: 68a1436bde00 ("mm: add swappiness=max arg to memory.reclaim for only anon reclaim")
Suggested-by: Qi Zheng <qi.zheng@linux.dev>
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
---
mm/vmscan.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4357a44ee876..098adc599720 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2492,6 +2492,17 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
enum scan_balance scan_balance;
enum lru_list lru;
+ /* Proactive reclaim initiated by userspace for anonymous memory only */
+ if (swappiness == SWAPPINESS_ANON_ONLY) {
+ WARN_ON_ONCE(!sc->proactive);
+ if (!can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) {
+ memset(nr, 0, sizeof(*nr) * NR_LRU_LISTS);
+ return;
+ }
+ scan_balance = SCAN_ANON;
+ goto out;
+ }
+
/* If we have no swap space, do not bother scanning anon folios. */
if (!sc->may_swap || !can_reclaim_anon_pages(memcg, pgdat->node_id, sc)) {
scan_balance = SCAN_FILE;
@@ -2510,13 +2521,6 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
goto out;
}
- /* Proactive reclaim initiated by userspace for anonymous memory only */
- if (swappiness == SWAPPINESS_ANON_ONLY) {
- WARN_ON_ONCE(!sc->proactive);
- scan_balance = SCAN_ANON;
- goto out;
- }
-
/*
* Do not apply any pressure balancing cleverness when the
* system is close to OOM, scan both anon and file equally
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim
2026-07-17 11:32 [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
@ 2026-07-17 11:32 ` Ridong
2026-07-17 12:16 ` Johannes Weiner
` (2 more replies)
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
2026-07-17 19:53 ` [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Andrew Morton
3 siblings, 3 replies; 14+ messages in thread
From: Ridong @ 2026-07-17 11:32 UTC (permalink / raw)
To: Andrew Morton, Johannes Weiner
Cc: Kairui Song, Qi Zheng, Shakeel Butt, Barry Song, Axel Rasmussen,
Yuanchu Xie, Wei Xu, David Hildenbrand, Michal Hocko,
Lorenzo Stoakes, Zhongkun He, Muchun Song, Davidlohr Bueso,
Roman Gushchin, linux-mm, linux-kernel, Ridong Chen, Ridong Chen
From: Ridong Chen <chenridong@xiaomi.com>
It has been observed that per-node proactive reclaim always returns
-EAGAIN when any error occurs. As discussed in the mailing list [1],
the interface should distinguish between cases where no reclaimable
memory is left and where another entity is concurrently using the
same interface. Propagate the real error code, consistent with how
memcg proactive reclaim handles errors.
[1] https://lore.kernel.org/all/20250717235604.2atyx2aobwowpge3@offworld/T/#m3514718be82a31b05726a49da9b61fbfc69a589e
Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
---
mm/vmscan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 098adc599720..45fbbefe0906 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -8008,7 +8008,7 @@ static ssize_t reclaim_store(struct device *dev,
int ret, nid = dev->id;
ret = user_proactive_reclaim((char *)buf, NULL, NODE_DATA(nid));
- return ret ? -EAGAIN : count;
+ return ret ? ret : count;
}
static DEVICE_ATTR_WO(reclaim);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim()
2026-07-17 11:32 [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
@ 2026-07-17 11:33 ` Ridong
2026-07-17 12:17 ` Johannes Weiner
` (2 more replies)
2026-07-17 19:53 ` [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Andrew Morton
3 siblings, 3 replies; 14+ messages in thread
From: Ridong @ 2026-07-17 11:33 UTC (permalink / raw)
To: Andrew Morton, Johannes Weiner
Cc: Kairui Song, Qi Zheng, Shakeel Butt, Barry Song, Axel Rasmussen,
Yuanchu Xie, Wei Xu, David Hildenbrand, Michal Hocko,
Lorenzo Stoakes, Zhongkun He, Muchun Song, Davidlohr Bueso,
Roman Gushchin, linux-mm, linux-kernel, Ridong Chen, Ridong Chen
From: Ridong Chen <chenridong@xiaomi.com>
Commit 57972c78e678 ("mm/vmscan: make __node_reclaim() more generic")
moved the scan_control construction out to the callers and passed the
struct in by pointer. After that change every use of the gfp mask inside
__node_reclaim() goes through sc->gfp_mask, leaving the gfp_mask parameter
unused. Just remove the dead parameter and update the callers accordingly.
No functional change.
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
---
mm/vmscan.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 45fbbefe0906..551c47a6cf6f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7729,7 +7729,7 @@ static unsigned long node_pagecache_reclaimable(struct pglist_data *pgdat)
/*
* Try to free up some pages from this node through reclaim.
*/
-static unsigned long __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask,
+static unsigned long __node_reclaim(struct pglist_data *pgdat,
unsigned long nr_pages,
struct scan_control *sc)
{
@@ -7821,7 +7821,7 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order)
if (test_and_set_bit_lock(PGDAT_RECLAIM_LOCKED, &pgdat->flags))
return NODE_RECLAIM_NOSCAN;
- ret = __node_reclaim(pgdat, gfp_mask, nr_pages, &sc) >= nr_pages;
+ ret = __node_reclaim(pgdat, nr_pages, &sc) >= nr_pages;
clear_bit_unlock(PGDAT_RECLAIM_LOCKED, &pgdat->flags);
if (ret)
@@ -7834,7 +7834,7 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order)
#else
-static unsigned long __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask,
+static unsigned long __node_reclaim(struct pglist_data *pgdat,
unsigned long nr_pages,
struct scan_control *sc)
{
@@ -7940,8 +7940,7 @@ int user_proactive_reclaim(char *buf,
&pgdat->flags))
return -EBUSY;
- reclaimed = __node_reclaim(pgdat, gfp_mask,
- batch_size, &sc);
+ reclaimed = __node_reclaim(pgdat, batch_size, &sc);
clear_bit_unlock(PGDAT_RECLAIM_LOCKED, &pgdat->flags);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
@ 2026-07-17 12:04 ` Johannes Weiner
2026-07-17 12:57 ` Muchun Song
2026-07-17 16:37 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Johannes Weiner @ 2026-07-17 12:04 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:32:58PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> As Qi mentioned [1], when swappiness=max (SWAPPINESS_ANON_ONLY) is set,
> the reclaim logic is expected to reclaim anonymous pages exclusively.
> However, due to the current ordering of checks in get_scan_count(),
> file pages may still be evicted if can_reclaim_anon_pages() returns
> false, which contradicts the semantics of SWAPPINESS_ANON_ONLY.
>
> Reproducer in a cgroup holding 64M of file cache, with no swap configured:
>
> Before (file cache is wrongly evicted):
> # cat memory.stat
> anon 196608
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> # cat memory.stat
> anon 208896
> file 4096 <- page cache evicted
> pgsteal_proactive 16400
> pgscan_proactive 16400
>
> After (file cache is left intact):
> # cat memory.stat
> anon 200704
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> -bash: echo: write error: Resource temporarily unavailable
> # cat memory.stat
> anon 208896
> file 67178496 <- page cache untouched
> pgsteal_proactive 0
> pgscan_proactive 0
>
> Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no
> anonymous pages are reclaimable, before falling back to file reclaim.
>
> [1] https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux.dev/
>
> Fixes: 68a1436bde00 ("mm: add swappiness=max arg to memory.reclaim for only anon reclaim")
> Suggested-by: Qi Zheng <qi.zheng@linux.dev>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
@ 2026-07-17 12:16 ` Johannes Weiner
2026-07-17 13:00 ` Muchun Song
2026-07-17 16:38 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Johannes Weiner @ 2026-07-17 12:16 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:32:59PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> It has been observed that per-node proactive reclaim always returns
> -EAGAIN when any error occurs. As discussed in the mailing list [1],
> the interface should distinguish between cases where no reclaimable
> memory is left and where another entity is concurrently using the
> same interface. Propagate the real error code, consistent with how
> memcg proactive reclaim handles errors.
>
> [1] https://lore.kernel.org/all/20250717235604.2atyx2aobwowpge3@offworld/T/#m3514718be82a31b05726a49da9b61fbfc69a589e
>
> Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim()
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
@ 2026-07-17 12:17 ` Johannes Weiner
2026-07-17 13:02 ` Muchun Song
2026-07-17 16:39 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Johannes Weiner @ 2026-07-17 12:17 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:33:00PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> Commit 57972c78e678 ("mm/vmscan: make __node_reclaim() more generic")
> moved the scan_control construction out to the callers and passed the
> struct in by pointer. After that change every use of the gfp mask inside
> __node_reclaim() goes through sc->gfp_mask, leaving the gfp_mask parameter
> unused. Just remove the dead parameter and update the callers accordingly.
> No functional change.
>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-17 12:04 ` Johannes Weiner
@ 2026-07-17 12:57 ` Muchun Song
2026-07-17 16:37 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Muchun Song @ 2026-07-17 12:57 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng,
Shakeel Butt, Barry Song, Axel Rasmussen, Yuanchu Xie, Wei Xu,
David Hildenbrand, Michal Hocko, Lorenzo Stoakes, Zhongkun He,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
> On Jul 17, 2026, at 19:32, Ridong <ridong.chen@linux.dev> wrote:
>
> From: Ridong Chen <chenridong@xiaomi.com>
>
> As Qi mentioned [1], when swappiness=max (SWAPPINESS_ANON_ONLY) is set,
> the reclaim logic is expected to reclaim anonymous pages exclusively.
> However, due to the current ordering of checks in get_scan_count(),
> file pages may still be evicted if can_reclaim_anon_pages() returns
> false, which contradicts the semantics of SWAPPINESS_ANON_ONLY.
>
> Reproducer in a cgroup holding 64M of file cache, with no swap configured:
>
> Before (file cache is wrongly evicted):
> # cat memory.stat
> anon 196608
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> # cat memory.stat
> anon 208896
> file 4096 <- page cache evicted
> pgsteal_proactive 16400
> pgscan_proactive 16400
>
> After (file cache is left intact):
> # cat memory.stat
> anon 200704
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> -bash: echo: write error: Resource temporarily unavailable
> # cat memory.stat
> anon 208896
> file 67178496 <- page cache untouched
> pgsteal_proactive 0
> pgscan_proactive 0
>
> Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no
> anonymous pages are reclaimable, before falling back to file reclaim.
>
> [1] https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux.dev/
>
> Fixes: 68a1436bde00 ("mm: add swappiness=max arg to memory.reclaim for only anon reclaim")
> Suggested-by: Qi Zheng <qi.zheng@linux.dev>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
2026-07-17 12:16 ` Johannes Weiner
@ 2026-07-17 13:00 ` Muchun Song
2026-07-17 16:38 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Muchun Song @ 2026-07-17 13:00 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng,
Shakeel Butt, Barry Song, Axel Rasmussen, Yuanchu Xie, Wei Xu,
David Hildenbrand, Michal Hocko, Lorenzo Stoakes, Zhongkun He,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
> On Jul 17, 2026, at 19:32, Ridong <ridong.chen@linux.dev> wrote:
>
> From: Ridong Chen <chenridong@xiaomi.com>
>
> It has been observed that per-node proactive reclaim always returns
> -EAGAIN when any error occurs. As discussed in the mailing list [1],
> the interface should distinguish between cases where no reclaimable
> memory is left and where another entity is concurrently using the
> same interface. Propagate the real error code, consistent with how
> memcg proactive reclaim handles errors.
>
> [1] https://lore.kernel.org/all/20250717235604.2atyx2aobwowpge3@offworld/T/#m3514718be82a31b05726a49da9b61fbfc69a589e
>
> Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
> ---
> mm/vmscan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 098adc599720..45fbbefe0906 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -8008,7 +8008,7 @@ static ssize_t reclaim_store(struct device *dev,
> int ret, nid = dev->id;
>
> ret = user_proactive_reclaim((char *)buf, NULL, NODE_DATA(nid));
> - return ret ? -EAGAIN : count;
> + return ret ? ret : count;
I usually use "? :" to omit ret. Just to be clear, I'm only sharing this
as a personal preference. I'm not suggesting that you actually need to change
it.
> }
>
> static DEVICE_ATTR_WO(reclaim);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim()
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
2026-07-17 12:17 ` Johannes Weiner
@ 2026-07-17 13:02 ` Muchun Song
2026-07-17 16:39 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Muchun Song @ 2026-07-17 13:02 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng,
Shakeel Butt, Barry Song, Axel Rasmussen, Yuanchu Xie, Wei Xu,
David Hildenbrand, Michal Hocko, Lorenzo Stoakes, Zhongkun He,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
> On Jul 17, 2026, at 19:33, Ridong <ridong.chen@linux.dev> wrote:
>
> From: Ridong Chen <chenridong@xiaomi.com>
>
> Commit 57972c78e678 ("mm/vmscan: make __node_reclaim() more generic")
> moved the scan_control construction out to the callers and passed the
> struct in by pointer. After that change every use of the gfp mask inside
> __node_reclaim() goes through sc->gfp_mask, leaving the gfp_mask parameter
> unused. Just remove the dead parameter and update the callers accordingly.
> No functional change.
>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-17 12:04 ` Johannes Weiner
2026-07-17 12:57 ` Muchun Song
@ 2026-07-17 16:37 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Shakeel Butt @ 2026-07-17 16:37 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:32:58PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> As Qi mentioned [1], when swappiness=max (SWAPPINESS_ANON_ONLY) is set,
> the reclaim logic is expected to reclaim anonymous pages exclusively.
> However, due to the current ordering of checks in get_scan_count(),
> file pages may still be evicted if can_reclaim_anon_pages() returns
> false, which contradicts the semantics of SWAPPINESS_ANON_ONLY.
>
> Reproducer in a cgroup holding 64M of file cache, with no swap configured:
>
> Before (file cache is wrongly evicted):
> # cat memory.stat
> anon 196608
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> # cat memory.stat
> anon 208896
> file 4096 <- page cache evicted
> pgsteal_proactive 16400
> pgscan_proactive 16400
>
> After (file cache is left intact):
> # cat memory.stat
> anon 200704
> file 67178496
> pgscan_proactive 0
> # echo "64M swappiness=max" > memory.reclaim
> -bash: echo: write error: Resource temporarily unavailable
> # cat memory.stat
> anon 208896
> file 67178496 <- page cache untouched
> pgsteal_proactive 0
> pgscan_proactive 0
>
> Fix this by bailing out early when SWAPPINESS_ANON_ONLY is set and no
> anonymous pages are reclaimable, before falling back to file reclaim.
>
> [1] https://lore.kernel.org/cgroups/7ddf3eee-5fe2-45f7-8614-c8936a039e04@linux.dev/
>
> Fixes: 68a1436bde00 ("mm: add swappiness=max arg to memory.reclaim for only anon reclaim")
> Suggested-by: Qi Zheng <qi.zheng@linux.dev>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
2026-07-17 12:16 ` Johannes Weiner
2026-07-17 13:00 ` Muchun Song
@ 2026-07-17 16:38 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Shakeel Butt @ 2026-07-17 16:38 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:32:59PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> It has been observed that per-node proactive reclaim always returns
> -EAGAIN when any error occurs. As discussed in the mailing list [1],
> the interface should distinguish between cases where no reclaimable
> memory is left and where another entity is concurrently using the
> same interface. Propagate the real error code, consistent with how
> memcg proactive reclaim handles errors.
>
> [1] https://lore.kernel.org/all/20250717235604.2atyx2aobwowpge3@offworld/T/#m3514718be82a31b05726a49da9b61fbfc69a589e
>
> Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim()
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
2026-07-17 12:17 ` Johannes Weiner
2026-07-17 13:02 ` Muchun Song
@ 2026-07-17 16:39 ` Shakeel Butt
2 siblings, 0 replies; 14+ messages in thread
From: Shakeel Butt @ 2026-07-17 16:39 UTC (permalink / raw)
To: Ridong
Cc: Andrew Morton, Johannes Weiner, Kairui Song, Qi Zheng, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, Jul 17, 2026 at 07:33:00PM +0800, Ridong wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> Commit 57972c78e678 ("mm/vmscan: make __node_reclaim() more generic")
> moved the scan_control construction out to the callers and passed the
> struct in by pointer. After that change every use of the gfp mask inside
> __node_reclaim() goes through sc->gfp_mask, leaving the gfp_mask parameter
> unused. Just remove the dead parameter and update the callers accordingly.
> No functional change.
>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim
2026-07-17 11:32 [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
` (2 preceding siblings ...)
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
@ 2026-07-17 19:53 ` Andrew Morton
3 siblings, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-07-17 19:53 UTC (permalink / raw)
To: Ridong
Cc: Johannes Weiner, Kairui Song, Qi Zheng, Shakeel Butt, Barry Song,
Axel Rasmussen, Yuanchu Xie, Wei Xu, David Hildenbrand,
Michal Hocko, Lorenzo Stoakes, Zhongkun He, Muchun Song,
Davidlohr Bueso, Roman Gushchin, linux-mm, linux-kernel,
Ridong Chen
On Fri, 17 Jul 2026 19:32:57 +0800 Ridong <ridong.chen@linux.dev> wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> Two 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().
Thanks. Sashiko want to know whether MGLRU should also be fixed:
https://sashiko.dev/#/patchset/20260717113300.214717-1-ridong.chen@linux.dev
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-07-17 19:53 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 11:32 [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Ridong
2026-07-17 11:32 ` [PATCH 1/3] mm/vmscan: fix anon-only reclaim evicting file pages when swappiness=max Ridong
2026-07-17 12:04 ` Johannes Weiner
2026-07-17 12:57 ` Muchun Song
2026-07-17 16:37 ` Shakeel Butt
2026-07-17 11:32 ` [PATCH 2/3] mm: vmscan: propagate real error code from per-node proactive reclaim Ridong
2026-07-17 12:16 ` Johannes Weiner
2026-07-17 13:00 ` Muchun Song
2026-07-17 16:38 ` Shakeel Butt
2026-07-17 11:33 ` [PATCH 3/3] mm: vmscan: drop unused gfp_mask parameter from __node_reclaim() Ridong
2026-07-17 12:17 ` Johannes Weiner
2026-07-17 13:02 ` Muchun Song
2026-07-17 16:39 ` Shakeel Butt
2026-07-17 19:53 ` [PATCH 0/3] mm/vmscan: fix swappiness=max and clean up per-node proactive reclaim Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.