]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/vmscan: filter empty page_list at the beginning
authorWei Yang <richard.weiyang@gmail.com>
Fri, 13 May 2022 03:23:00 +0000 (20:23 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 13 May 2022 14:20:14 +0000 (07:20 -0700)
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/20220429014426.29223-1-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c

index 9ff3cc2a941aa7878a9bf41aed02593c323a178f..43883ff89c1a0fe2109ce9f598bf1307a8a65fbb 100644 (file)
@@ -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);