linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning
Date: Tue, 26 Apr 2022 02:17:42 +0000	[thread overview]
Message-ID: <20220426021743.21007-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220426021743.21007-1-richard.weiyang@gmail.com>

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.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/vmscan.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9b5ce5778e9b..3a36ebd6295d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2533,9 +2533,12 @@ unsigned long reclaim_pages(struct list_head *page_list)
 		.no_demotion = 1,
 	};
 
+	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);
@@ -2557,17 +2560,15 @@ unsigned long reclaim_pages(struct list_head *page_list)
 		}
 
 		nid = NUMA_NO_NODE;
-	}
+	} while (!list_empty(page_list));
 
-	if (!list_empty(&node_page_list)) {
-		nr_reclaimed += shrink_page_list(&node_page_list,
-						NODE_DATA(nid),
-						&sc, &dummy_stat, false);
-		while (!list_empty(&node_page_list)) {
-			page = lru_to_page(&node_page_list);
-			list_del(&page->lru);
-			putback_lru_page(page);
-		}
+	nr_reclaimed += shrink_page_list(&node_page_list,
+					NODE_DATA(nid),
+					&sc, &dummy_stat, false);
+	while (!list_empty(&node_page_list)) {
+		page = lru_to_page(&node_page_list);
+		list_del(&page->lru);
+		putback_lru_page(page);
 	}
 
 	memalloc_noreclaim_restore(noreclaim_flag);
-- 
2.33.1



  reply	other threads:[~2022-04-26  2:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  2:17 [PATCH 1/3] mm/vmscan: not necessary to re-init the list for each iteration Wei Yang
2022-04-26  2:17 ` Wei Yang [this message]
2022-04-26 21:47   ` [PATCH 2/3] mm/vmscan: filter empty page_list at the beginning Andrew Morton
2022-04-27 23:25     ` Wei Yang
2022-04-27 23:29       ` Andrew Morton
2022-04-26  2:17 ` [PATCH 3/3] mm/vmscan: not use NUMA_NO_NODE as indicator of page on different node Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220426021743.21007-2-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).