From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: kosaki.motohiro@jp.fujitsu.com, linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/4] vmscan: make lru_index() helper function
Date: Fri, 27 Nov 2009 09:18:40 +0900 (JST) [thread overview]
Message-ID: <20091127091755.A7CF.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20091127091357.A7CC.A69D9226@jp.fujitsu.com>
Current lru calculation (e.g. LRU_ACTIVE + file * LRU_FILE) is a bit
ugly.
To make helper function improve code readability a bit.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/vmscan.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index a58ff15..7e0245d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -156,6 +156,16 @@ static unsigned long zone_nr_lru_pages(struct zone *zone,
return zone_page_state(zone, NR_LRU_BASE + lru);
}
+static inline enum lru_list lru_index(int active, int file)
+{
+ int lru = LRU_BASE;
+ if (active)
+ lru += LRU_ACTIVE;
+ if (file)
+ lru += LRU_FILE;
+
+ return lru;
+}
/*
* Add a shrinker callback to be called from the vm
@@ -978,13 +988,8 @@ static unsigned long isolate_pages_global(unsigned long nr,
struct mem_cgroup *mem_cont,
int active, int file)
{
- int lru = LRU_BASE;
- if (active)
- lru += LRU_ACTIVE;
- if (file)
- lru += LRU_FILE;
- return isolate_lru_pages(nr, &z->lru[lru].list, dst, scanned, order,
- mode, file);
+ return isolate_lru_pages(nr, &z->lru[lru_index(active, file)].list,
+ dst, scanned, order, mode, file);
}
/*
@@ -1373,10 +1378,8 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
*/
reclaim_stat->recent_rotated[file] += nr_rotated;
- move_active_pages_to_lru(zone, &l_active,
- LRU_ACTIVE + file * LRU_FILE);
- move_active_pages_to_lru(zone, &l_inactive,
- LRU_BASE + file * LRU_FILE);
+ move_active_pages_to_lru(zone, &l_active, lru_index(1, file));
+ move_active_pages_to_lru(zone, &l_inactive, lru_index(0, file));
__mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken);
spin_unlock_irq(&zone->lru_lock);
}
--
1.6.5.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-11-27 0:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-27 0:17 [PATCH 1/4] vmscan: more simplify shrink_inactive_list() KOSAKI Motohiro
2009-11-27 0:18 ` KOSAKI Motohiro [this message]
2009-11-27 5:44 ` [PATCH 2/4] vmscan: make lru_index() helper function Vincent Li
2009-11-27 5:47 ` KOSAKI Motohiro
2009-11-27 5:54 ` Vincent Li
2009-11-27 0:19 ` [PATCH 3/4] vmscan: move PGDEACTIVATE modification to shrink_active_list() KOSAKI Motohiro
2009-11-27 0:23 ` [RFC][PATCH 4/4] vmscan: vmscan don't use pcp list KOSAKI Motohiro
2009-11-27 16:17 ` Mel Gorman
2009-12-02 7:15 ` KOSAKI Motohiro
2009-12-02 14:25 ` Mel Gorman
2009-11-27 19:25 ` Christoph Lameter
2009-12-04 8:26 ` [PATCH 1/4] vmscan: more simplify shrink_inactive_list() KOSAKI Motohiro
2009-12-06 4:19 ` Wu Fengguang
2009-12-07 5:48 ` KOSAKI Motohiro
2009-12-06 5:41 ` [PATCH] vmscan: aligned scan batching Wu Fengguang
2009-12-07 6:17 ` KOSAKI Motohiro
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=20091127091755.A7CF.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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