In the zone_reclaimable_pages() function, if the page counts for NR_ZONE_INACTIVE_FILE,
NR_ZONE_ACTIVE_FILE, NR_ZONE_INACTIVE_ANON, and NR_ZONE_ACTIVE_ANON are all zero,
the function returns the number of free pages as the result.
In this case, when should_reclaim_retry() calculates reclaimable pages,
it will inadvertently double-count the free pages in its accounting.
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 34410d24dc15..a9aaefdba7a2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -393,14 +393,7 @@ unsigned long zone_reclaimable_pages(struct zone *zone)
if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL))
nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) +
zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON);
- /*
- * If there are no reclaimable file-backed or anonymous pages,
- * ensure zones with sufficient free pages are not skipped.
- * This prevents zones like DMA32 from being ignored in reclaim
- * scenarios where they can still help alleviate memory pressure.
- */
- if (nr == 0)
- nr = zone_page_state_snapshot(zone, NR_FREE_PAGES);
+
return nr;
}
@@ -6417,7 +6410,7 @@ 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))
+ if (!zone_reclaimable_pages(zone) && zone_page_state_snapshot(zone, NR_FREE_PAGES))
continue;
signed-off-by: liuqiqi <liuqiqi@kylinos.cn>
On Mon, Aug 11, 2025 at 05:53:30PM +0800, liuqiqi@kylinos.cn wrote: > In the zone_reclaimable_pages() function, if the page counts for NR_ZONE_INACTIVE_FILE, > NR_ZONE_ACTIVE_FILE, NR_ZONE_INACTIVE_ANON, and NR_ZONE_ACTIVE_ANON are all zero, > the function returns the number of free pages as the result. > > In this case, when should_reclaim_retry() calculates reclaimable pages, > it will inadvertently double-count the free pages in its accounting. > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 34410d24dc15..a9aaefdba7a2 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -393,14 +393,7 @@ unsigned long zone_reclaimable_pages(struct zone *zone) > if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL)) > nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) + > zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON); > - /* > - * If there are no reclaimable file-backed or anonymous pages, > - * ensure zones with sufficient free pages are not skipped. > - * This prevents zones like DMA32 from being ignored in reclaim > - * scenarios where they can still help alleviate memory pressure. > - */ > - if (nr == 0) > - nr = zone_page_state_snapshot(zone, NR_FREE_PAGES); > + > return nr; > } > > @@ -6417,7 +6410,7 @@ 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)) > + if (!zone_reclaimable_pages(zone) && zone_page_state_snapshot(zone, NR_FREE_PAGES)) > continue; > > signed-off-by: liuqiqi <liuqiqi@kylinos.cn> > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - Your patch does not have a Signed-off-by: line. Please read the kernel file, Documentation/process/submitting-patches.rst and resend it after adding that line. Note, the line needs to be in the body of the email, before the patch, not at the bottom of the patch or in the email signature. - You did not specify a description of why the patch is needed, or possibly, any description at all, in the email body. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what is needed in order to properly describe the change. - You did not submit this patch to the proper subsystem and maintainers. - You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what a proper Subject: line should look like. - It looks like you did not use your "real" name for the patch on either the Signed-off-by: line, or the From: line (both of which have to match). Please read the kernel file, Documentation/process/submitting-patches.rst for how to do this correctly. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
© 2016 - 2025 Red Hat, Inc.