aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Yang <[email protected]>2022-05-12 20:23:00 -0700
committerAndrew Morton <[email protected]>2022-05-13 07:20:14 -0700
commit1ae65e2749b0a3d236fc17d0eca5ea5f6f2c0032 (patch)
treeb00635abbf3c8d1f8e96461f8553ff4372f5bd42
parentf19a27e399c4354b91d608dd77f33877f613224a (diff)
mm/vmscan: filter empty page_list at the beginning
node_page_list would always be !empty on finishing the loop, except page_list is empty. Let's handle empty page_list before doing any real work including touching PF_MEMALLOC flag. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Wei Yang <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/vmscan.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9ff3cc2a941a..43883ff89c1a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2568,9 +2568,12 @@ unsigned long reclaim_pages(struct list_head *page_list)
struct page *page;
unsigned int noreclaim_flag;
+ if (list_empty(page_list))
+ return nr_reclaimed;
+
noreclaim_flag = memalloc_noreclaim_save();
- while (!list_empty(page_list)) {
+ do {
page = lru_to_page(page_list);
if (nid == NUMA_NO_NODE)
nid = page_to_nid(page);
@@ -2583,10 +2586,9 @@ unsigned long reclaim_pages(struct list_head *page_list)
nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid));
nid = NUMA_NO_NODE;
- }
+ } while (!list_empty(page_list));
- if (!list_empty(&node_page_list))
- nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid));
+ nr_reclaimed += reclaim_page_list(&node_page_list, NODE_DATA(nid));
memalloc_noreclaim_restore(noreclaim_flag);