linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: qiwuchen55@gmail.com
To: akpm@linux-foundation.org
Cc: alexander.h.duyck@linux.intel.com, willy@infradead.org,
	vbabka@suse.cz, pankaj.gupta.linux@gmail.com, bhe@redhat.com,
	mhocko@kernel.org, linux-mm@kvack.org,
	chenqiwu <chenqiwu@xiaomi.com>
Subject: [PATCH 2/2] mm/vmscan: make several optimizations for isolate_lru_pages()
Date: Fri,  3 Apr 2020 15:08:53 +0800	[thread overview]
Message-ID: <1585897733-4696-2-git-send-email-qiwuchen55@gmail.com> (raw)
In-Reply-To: <1585897733-4696-1-git-send-email-qiwuchen55@gmail.com>

From: chenqiwu <chenqiwu@xiaomi.com>

1) Simplify the code for initializing some variables.
1) Add const modifier to decorate the mode variable.
2) Define a page_zoneidx variable to reduce the redundant code
of page_zonenum().

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 mm/vmscan.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8763705..cf90e8b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1639,16 +1639,15 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
 	struct list_head *src = &lruvec->lists[lru];
 	unsigned long nr_taken = 0;
 	unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 };
-	unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
+	unsigned long nr_skipped[MAX_NR_ZONES] = { 0 };
 	unsigned long skipped = 0;
-	unsigned long scan, total_scan, nr_pages;
+	unsigned long scan = 0, total_scan = 0, nr_pages;
 	LIST_HEAD(pages_skipped);
-	isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED);
+	const isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED);
 
-	total_scan = 0;
-	scan = 0;
 	while (scan < nr_to_scan && !list_empty(src)) {
 		struct page *page;
+		enum zone_type page_zoneidx;
 
 		page = lru_to_page(src);
 		prefetchw_prev_lru_page(page, src, flags);
@@ -1658,9 +1657,10 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
 		nr_pages = compound_nr(page);
 		total_scan += nr_pages;
 
-		if (page_zonenum(page) > sc->reclaim_idx) {
+		page_zoneidx = page_zonenum(page);
+		if (page_zoneidx > sc->reclaim_idx) {
 			list_move(&page->lru, &pages_skipped);
-			nr_skipped[page_zonenum(page)] += nr_pages;
+			nr_skipped[page_zoneidx] += nr_pages;
 			continue;
 		}
 
@@ -1678,7 +1678,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
 		switch (__isolate_lru_page(page, mode)) {
 		case 0:
 			nr_taken += nr_pages;
-			nr_zone_taken[page_zonenum(page)] += nr_pages;
+			nr_zone_taken[page_zoneidx] += nr_pages;
 			list_move(&page->lru, dst);
 			break;
 
-- 
1.9.1



      reply	other threads:[~2020-04-03  7:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03  7:08 [PATCH 1/2] mm: Replace zero-length array with flexible-array member qiwuchen55
2020-04-03  7:08 ` qiwuchen55 [this message]

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=1585897733-4696-2-git-send-email-qiwuchen55@gmail.com \
    --to=qiwuchen55@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.h.duyck@linux.intel.com \
    --cc=bhe@redhat.com \
    --cc=chenqiwu@xiaomi.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=pankaj.gupta.linux@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.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