Skip to contentSkip to conversation

mm/vmscan: drop the combined limit gate in __node_reclaim()

PATCH Applied Ridong Chen 4 participants 4 messages Aug 26 – Aug 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmscan: drop the combined limit gate in __node_reclaim()

From: Ridong Chen <[email protected]>

__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/[email protected]

Fixes b980077899ea ("mm: introduce per-node proactive reclaim interface")
Assisted-by Claude:claude-opus-4-8
---
 mm/vmscan.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
mm/vmscan.c +3 -10
index f11491ee9ed5..6dff207ad8c6 100644
@@ -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);
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Ridong Chen

From: Ridong Chen <[email protected]>

__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.

Quoted 5 lines

[1] https://sashiko.dev/#/patchset/[email protected]

Fixes b980077899ea ("mm: introduce per-node proactive reclaim interface")
Assisted-by Claude:claude-opus-4-8

Thanks!

Quoted 30 lines
---
 mm/vmscan.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
mm/vmscan.c +3 -10
index f11491ee9ed5..6dff207ad8c6 100644
@@ -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);
Signature · 1 line
2.34.1
Signature · 2 lines
Michal Hocko
SUSE Labs
reviewer Acked-by on v1 1/1
#2 lore raw
In reply to Ridong Chen
Quoted 20 lines · Ridong Chen

From: Ridong Chen <[email protected]>

__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.

Quoted 5 lines

[1] https://sashiko.dev/#/patchset/[email protected]

Fixes b980077899ea ("mm: introduce per-node proactive reclaim interface")
Assisted-by Claude:claude-opus-4-8
Acked-by on v1 1/1
#3 lore raw
In reply to Ridong Chen
Quoted 20 lines · Ridong Chen

From: Ridong Chen <[email protected]>

__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.

Quoted 5 lines

[1] https://sashiko.dev/#/patchset/[email protected]

Fixes b980077899ea ("mm: introduce per-node proactive reclaim interface")
Assisted-by Claude:claude-opus-4-8
Quoted 31 lines

---
mm/vmscan.c | 13 +++----------

1 file changed, 3 insertions(+), 10 deletions(-)
mm/vmscan.c +3 -11
index f11491ee9ed5..6dff207ad8c6 100644
@@ -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