mm: vmscan: fix inverted free page check in allow_direct_reclaim()
Subsystems (4)
PATCH 1/1 mm: vmscan: fix inverted free page check in allow_direct_reclaim()
Commit 4bd22a7ae574 ("mm: fix duplicate accounting of free pages in should_reclaim_retry()") removed the free-page fallback from zone_reclaimable_pages() and added an explicit check in allow_direct_reclaim().
Before that change, allow_direct_reclaim() skipped a zone only when it had neither reclaimable nor free pages. The new check was inverted: it skips a zone when it has no reclaimable pages but does have free pages. It also keeps a zone that has neither, adding its watermark without adding any free pages.
As a result, allow_direct_reclaim() can keep returning false and leave direct reclaimers throttled even though free pages are available.
Negate the free-page test to restore the previous behavior while keeping free pages out of zone_reclaimable_pages().
--- mm/vmscan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmscan.c +2 -1
@@ -6858,7 +6858,8 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)return true;for_each_managed_zone_pgdat (zone, pgdat, i,ZONE_NORMAL ) { -if (!zone_reclaimable_pages (zone) &&zone_page_state_snapshot (zone,NR_FREE_PAGES )) +if (!zone_reclaimable_pages (zone) && + !zone_page_state_snapshot (zone,NR_FREE_PAGES ))continue ; pfmemalloc_reserve +=min_wmark_pages (zone);
base-commit: 890dc639d8a33e674caa7ea9993dbd2416660447
Signature · 1 line
2.43.7
CC more relevant people
Quoted 14 lines · Zelin Deng
Commit
4bd22a7ae574("mm: fix duplicate accounting of free pages inshould_reclaim_retry()") removed the free-page fallback fromzone_reclaimable_pages()and added an explicit check inallow_direct_reclaim().Before that change,
allow_direct_reclaim()skipped a zone only when it had neither reclaimable nor free pages. The new check was inverted: it skips a zone when it has no reclaimable pages but does have free pages. It also keeps a zone that has neither, adding its watermark without adding any free pages.As a result,
allow_direct_reclaim()can keep returning false and leave direct reclaimers throttled even though free pages are available.
Quoted 8 lines
Negate the free-page test to restore the previous behavior while keeping free pages out of
zone_reclaimable_pages().Fixes 4bd22a7ae574 ("mm: fix duplicate accounting of free pages in should_reclaim_retry()")Cc Baolin Wang <[email protected]>Signed-off-by Zelin Deng <[email protected]>---
The fix looks good to me.
+ mm-vmscan-fix-inverted-free-page-check-in-allow_direct_reclaim.patch added to mm-new branch
In reply to Zelin DengThe patch titled Subject: mm: vmscan: fix inverted free page check in allow_direct_reclaim() has been added to the -mm mm-new branch. Its filename is…
The patch titled
Subject: mm: vmscan: fix inverted free page check in allow_direct_reclaim()
has been added to the -mm mm-new branch. Its filename is
mm-vmscan-fix-inverted-free-page-check-in-allow_direct_reclaim.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmscan-fix-inverted-free-page-check-in-allow_direct_reclaim.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Zelin Deng <[email protected]>
Subject: mm: vmscan: fix inverted free page check in allow_direct_reclaim()
Date: Mon, 30 Nov 2026 14:46:52 +0800
Commit 4bd22a7ae574 ("mm: fix duplicate accounting of free pages in should_reclaim_retry()") removed the free-page fallback from zone_reclaimable_pages() and added an explicit check in allow_direct_reclaim().
Before that change, allow_direct_reclaim() skipped a zone only when it had neither reclaimable nor free pages. The new check was inverted: it skips a zone when it has no reclaimable pages but does have free pages. It also keeps a zone that has neither, adding its watermark without adding any free pages.
As a result, allow_direct_reclaim() can keep returning false and leave direct reclaimers throttled even though free pages are available.
Negate the free-page test to restore the previous behavior while keeping free pages out of zone_reclaimable_pages().
mm/vmscan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmscan.c renamed from mm/vmscan.c~mm-vmscan-fix-inverted-free-page-check-in-allow_direct_reclaim +2 -1
@@ -6940,7 +6940,8 @@ static bool allow_direct_reclaim(pg_datareturn true;for_each_managed_zone_pgdat (zone, pgdat, i,ZONE_NORMAL ) { -if (!zone_reclaimable_pages (zone) &&zone_page_state_snapshot (zone,NR_FREE_PAGES )) +if (!zone_reclaimable_pages (zone) && + !zone_page_state_snapshot (zone,NR_FREE_PAGES ))continue ; pfmemalloc_reserve +=min_wmark_pages (zone);
_
Patches currently in -mm which might be from [email protected] are
mm-vmscan-fix-inverted-free-page-check-in-allow_direct_reclaim.patch