Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim()
@ 2026-08-26 12:44 Ridong Chen
  2026-08-26 13:51 ` Michal Hocko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ridong Chen @ 2026-08-26 12:44 UTC (permalink / raw)
  To: Andrew Morton, Johannes Weiner
  Cc: David Hildenbrand, Michal Hocko, Qi Zheng, Shakeel Butt,
	Lorenzo Stoakes, Kairui Song, Barry Song, Axel Rasmussen,
	Yuanchu Xie, Wei Xu, Davidlohr Bueso, Roman Gushchin, linux-mm,
	linux-kernel, Ridong Chen, Ridong Chen

From: Ridong Chen <chenridong@xiaomi.com>

__node_reclaim() is called from two paths: node_reclaim() and
user_proactive_reclaim().

node_reclaim() already bails out early unless node_pagecache_reclaimable()
is over pgdat->min_unmapped_pages or the reclaimable slab is over
pgdat->min_slab_pages.  The identical check inside __node_reclaim() that
guards the shrink_node() loop is therefore redundant for this path.

user_proactive_reclaim() is proactive reclaim driven by userspace and
should not be gated by the per-node min_unmapped_pages / min_slab_pages
limits at all [1].  With the gate in place, a proactive request is silently
turned into a no-op whenever the node happens to sit below both
thresholds.

Drop the gate in __node_reclaim() and always run the shrink_node() loop.
The node_reclaim() path is unchanged, since its caller has already applied
the same test; the proactive path is no longer wrongly gated.

[1] https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev
Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/vmscan.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index f11491ee9ed5..6dff207ad8c6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7851,16 +7851,9 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat,
 	noreclaim_flag = memalloc_noreclaim_save();
 	set_task_reclaim_state(p, &sc->reclaim_state);
 
-	if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages ||
-	    node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B) > pgdat->min_slab_pages) {
-		/*
-		 * Free memory by calling shrink node with increasing
-		 * priorities until we have enough memory freed.
-		 */
-		do {
-			shrink_node(pgdat, sc);
-		} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
-	}
+	do {
+		shrink_node(pgdat, sc);
+	} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
 
 	set_task_reclaim_state(p, NULL);
 	memalloc_noreclaim_restore(noreclaim_flag);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim()
  2026-08-26 12:44 [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim() Ridong Chen
@ 2026-08-26 13:51 ` Michal Hocko
  2026-08-26 18:30 ` Shakeel Butt
  2026-08-27 13:56 ` Davidlohr Bueso
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2026-08-26 13:51 UTC (permalink / raw)
  To: Ridong Chen
  Cc: Andrew Morton, Johannes Weiner, David Hildenbrand, Qi Zheng,
	Shakeel Butt, Lorenzo Stoakes, Kairui Song, Barry Song,
	Axel Rasmussen, Yuanchu Xie, Wei Xu, Davidlohr Bueso,
	Roman Gushchin, linux-mm, linux-kernel, Ridong Chen

On Wed 26-08-26 20:44:09, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
> 
> __node_reclaim() is called from two paths: node_reclaim() and
> user_proactive_reclaim().
> 
> node_reclaim() already bails out early unless node_pagecache_reclaimable()
> is over pgdat->min_unmapped_pages or the reclaimable slab is over
> pgdat->min_slab_pages.  The identical check inside __node_reclaim() that
> guards the shrink_node() loop is therefore redundant for this path.
> 
> user_proactive_reclaim() is proactive reclaim driven by userspace and
> should not be gated by the per-node min_unmapped_pages / min_slab_pages
> limits at all [1].  With the gate in place, a proactive request is silently
> turned into a no-op whenever the node happens to sit below both
> thresholds.
> 
> Drop the gate in __node_reclaim() and always run the shrink_node() loop.
> The node_reclaim() path is unchanged, since its caller has already applied
> the same test; the proactive path is no longer wrongly gated.
> 
> [1] https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev
> Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!

> ---
>  mm/vmscan.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index f11491ee9ed5..6dff207ad8c6 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -7851,16 +7851,9 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat,
>  	noreclaim_flag = memalloc_noreclaim_save();
>  	set_task_reclaim_state(p, &sc->reclaim_state);
>  
> -	if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages ||
> -	    node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B) > pgdat->min_slab_pages) {
> -		/*
> -		 * Free memory by calling shrink node with increasing
> -		 * priorities until we have enough memory freed.
> -		 */
> -		do {
> -			shrink_node(pgdat, sc);
> -		} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
> -	}
> +	do {
> +		shrink_node(pgdat, sc);
> +	} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
>  
>  	set_task_reclaim_state(p, NULL);
>  	memalloc_noreclaim_restore(noreclaim_flag);
> -- 
> 2.34.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim()
  2026-08-26 12:44 [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim() Ridong Chen
  2026-08-26 13:51 ` Michal Hocko
@ 2026-08-26 18:30 ` Shakeel Butt
  2026-08-27 13:56 ` Davidlohr Bueso
  2 siblings, 0 replies; 4+ messages in thread
From: Shakeel Butt @ 2026-08-26 18:30 UTC (permalink / raw)
  To: Ridong Chen
  Cc: Andrew Morton, Johannes Weiner, David Hildenbrand, Michal Hocko,
	Qi Zheng, Lorenzo Stoakes, Kairui Song, Barry Song,
	Axel Rasmussen, Yuanchu Xie, Wei Xu, Davidlohr Bueso,
	Roman Gushchin, linux-mm, linux-kernel, Ridong Chen

On Wed, Aug 26, 2026 at 08:44:09PM +0800, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
> 
> __node_reclaim() is called from two paths: node_reclaim() and
> user_proactive_reclaim().
> 
> node_reclaim() already bails out early unless node_pagecache_reclaimable()
> is over pgdat->min_unmapped_pages or the reclaimable slab is over
> pgdat->min_slab_pages.  The identical check inside __node_reclaim() that
> guards the shrink_node() loop is therefore redundant for this path.
> 
> user_proactive_reclaim() is proactive reclaim driven by userspace and
> should not be gated by the per-node min_unmapped_pages / min_slab_pages
> limits at all [1].  With the gate in place, a proactive request is silently
> turned into a no-op whenever the node happens to sit below both
> thresholds.
> 
> Drop the gate in __node_reclaim() and always run the shrink_node() loop.
> The node_reclaim() path is unchanged, since its caller has already applied
> the same test; the proactive path is no longer wrongly gated.
> 
> [1] https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev
> Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim()
  2026-08-26 12:44 [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim() Ridong Chen
  2026-08-26 13:51 ` Michal Hocko
  2026-08-26 18:30 ` Shakeel Butt
@ 2026-08-27 13:56 ` Davidlohr Bueso
  2 siblings, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2026-08-27 13:56 UTC (permalink / raw)
  To: Ridong Chen
  Cc: Andrew Morton, Johannes Weiner, David Hildenbrand, Michal Hocko,
	Qi Zheng, Shakeel Butt, Lorenzo Stoakes, Kairui Song, Barry Song,
	Axel Rasmussen, Yuanchu Xie, Wei Xu, Roman Gushchin, linux-mm,
	linux-kernel, Ridong Chen

On Wed, 26 Aug 2026, Ridong Chen wrote:

>From: Ridong Chen <chenridong@xiaomi.com>
>
>__node_reclaim() is called from two paths: node_reclaim() and
>user_proactive_reclaim().
>
>node_reclaim() already bails out early unless node_pagecache_reclaimable()
>is over pgdat->min_unmapped_pages or the reclaimable slab is over
>pgdat->min_slab_pages.  The identical check inside __node_reclaim() that
>guards the shrink_node() loop is therefore redundant for this path.
>
>user_proactive_reclaim() is proactive reclaim driven by userspace and
>should not be gated by the per-node min_unmapped_pages / min_slab_pages
>limits at all [1].  With the gate in place, a proactive request is silently
>turned into a no-op whenever the node happens to sit below both
>thresholds.
>
>Drop the gate in __node_reclaim() and always run the shrink_node() loop.
>The node_reclaim() path is unchanged, since its caller has already applied
>the same test; the proactive path is no longer wrongly gated.
>
>[1] https://sashiko.dev/#/patchset/20260723045718.2052070-1-ridong.chen@linux.dev
>Fixes: b980077899ea ("mm: introduce per-node proactive reclaim interface")
>Assisted-by: Claude:claude-opus-4-8
>Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
>Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Davidlohr Bueso <dave@stgolabs.net>

>---
> mm/vmscan.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
>diff --git a/mm/vmscan.c b/mm/vmscan.c
>index f11491ee9ed5..6dff207ad8c6 100644
>--- a/mm/vmscan.c
>+++ b/mm/vmscan.c
>@@ -7851,16 +7851,9 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat,
>	noreclaim_flag = memalloc_noreclaim_save();
>	set_task_reclaim_state(p, &sc->reclaim_state);
>
>-	if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages ||
>-	    node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B) > pgdat->min_slab_pages) {
>-		/*
>-		 * Free memory by calling shrink node with increasing
>-		 * priorities until we have enough memory freed.
>-		 */
>-		do {
>-			shrink_node(pgdat, sc);
>-		} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
>-	}
>+	do {
>+		shrink_node(pgdat, sc);
>+	} while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0);
>
>	set_task_reclaim_state(p, NULL);
>	memalloc_noreclaim_restore(noreclaim_flag);
>--
>2.34.1
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-27 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 12:44 [PATCH] mm/vmscan: drop the combined limit gate in __node_reclaim() Ridong Chen
2026-08-26 13:51 ` Michal Hocko
2026-08-26 18:30 ` Shakeel Butt
2026-08-27 13:56 ` Davidlohr Bueso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox