diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2009-09-21 20:02:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:35 -0400 |
commit | 401a8e1c1670085b8177330ca47d4f7c4ac88761 (patch) | |
tree | 5883daaed42fa2a186e5769bab1c10535dc39a41 | |
parent | b7c46d151cb82856a429709d1227ba1648028232 (diff) |
mm: introduce page_lru_base_type()
Instead of abusing page_is_file_cache() for LRU list index arithmetic, add
another helper with a more appropriate name and convert the non-boolean
users of page_is_file_cache() accordingly.
This new helper gives the LRU base type a page is supposed to live on,
inactive anon or inactive file.
[hugh.dickins@tiscali.co.uk: convert del_page_from_lru() also]
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mm_inline.h | 23 | ||||
-rw-r--r-- | mm/swap.c | 4 | ||||
-rw-r--r-- | mm/vmscan.c | 6 |
3 files changed, 24 insertions, 9 deletions
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 7fbb97267556..99977ff45b83 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h | |||
@@ -39,21 +39,36 @@ del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l) | |||
39 | mem_cgroup_del_lru_list(page, l); | 39 | mem_cgroup_del_lru_list(page, l); |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | ||
43 | * page_lru_base_type - which LRU list type should a page be on? | ||
44 | * @page: the page to test | ||
45 | * | ||
46 | * Used for LRU list index arithmetic. | ||
47 | * | ||
48 | * Returns the base LRU type - file or anon - @page should be on. | ||
49 | */ | ||
50 | static inline enum lru_list page_lru_base_type(struct page *page) | ||
51 | { | ||
52 | if (page_is_file_cache(page)) | ||
53 | return LRU_INACTIVE_FILE; | ||
54 | return LRU_INACTIVE_ANON; | ||
55 | } | ||
56 | |||
42 | static inline void | 57 | static inline void |
43 | del_page_from_lru(struct zone *zone, struct page *page) | 58 | del_page_from_lru(struct zone *zone, struct page *page) |
44 | { | 59 | { |
45 | enum lru_list l = LRU_BASE; | 60 | enum lru_list l; |
46 | 61 | ||
47 | list_del(&page->lru); | 62 | list_del(&page->lru); |
48 | if (PageUnevictable(page)) { | 63 | if (PageUnevictable(page)) { |
49 | __ClearPageUnevictable(page); | 64 | __ClearPageUnevictable(page); |
50 | l = LRU_UNEVICTABLE; | 65 | l = LRU_UNEVICTABLE; |
51 | } else { | 66 | } else { |
67 | l = page_lru_base_type(page); | ||
52 | if (PageActive(page)) { | 68 | if (PageActive(page)) { |
53 | __ClearPageActive(page); | 69 | __ClearPageActive(page); |
54 | l += LRU_ACTIVE; | 70 | l += LRU_ACTIVE; |
55 | } | 71 | } |
56 | l += page_is_file_cache(page); | ||
57 | } | 72 | } |
58 | __dec_zone_state(zone, NR_LRU_BASE + l); | 73 | __dec_zone_state(zone, NR_LRU_BASE + l); |
59 | mem_cgroup_del_lru_list(page, l); | 74 | mem_cgroup_del_lru_list(page, l); |
@@ -68,14 +83,14 @@ del_page_from_lru(struct zone *zone, struct page *page) | |||
68 | */ | 83 | */ |
69 | static inline enum lru_list page_lru(struct page *page) | 84 | static inline enum lru_list page_lru(struct page *page) |
70 | { | 85 | { |
71 | enum lru_list lru = LRU_BASE; | 86 | enum lru_list lru; |
72 | 87 | ||
73 | if (PageUnevictable(page)) | 88 | if (PageUnevictable(page)) |
74 | lru = LRU_UNEVICTABLE; | 89 | lru = LRU_UNEVICTABLE; |
75 | else { | 90 | else { |
91 | lru = page_lru_base_type(page); | ||
76 | if (PageActive(page)) | 92 | if (PageActive(page)) |
77 | lru += LRU_ACTIVE; | 93 | lru += LRU_ACTIVE; |
78 | lru += page_is_file_cache(page); | ||
79 | } | 94 | } |
80 | 95 | ||
81 | return lru; | 96 | return lru; |
@@ -118,7 +118,7 @@ static void pagevec_move_tail(struct pagevec *pvec) | |||
118 | spin_lock(&zone->lru_lock); | 118 | spin_lock(&zone->lru_lock); |
119 | } | 119 | } |
120 | if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { | 120 | if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { |
121 | int lru = page_is_file_cache(page); | 121 | int lru = page_lru_base_type(page); |
122 | list_move_tail(&page->lru, &zone->lru[lru].list); | 122 | list_move_tail(&page->lru, &zone->lru[lru].list); |
123 | pgmoved++; | 123 | pgmoved++; |
124 | } | 124 | } |
@@ -181,7 +181,7 @@ void activate_page(struct page *page) | |||
181 | spin_lock_irq(&zone->lru_lock); | 181 | spin_lock_irq(&zone->lru_lock); |
182 | if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { | 182 | if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { |
183 | int file = page_is_file_cache(page); | 183 | int file = page_is_file_cache(page); |
184 | int lru = LRU_BASE + file; | 184 | int lru = page_lru_base_type(page); |
185 | del_page_from_lru_list(zone, page, lru); | 185 | del_page_from_lru_list(zone, page, lru); |
186 | 186 | ||
187 | SetPageActive(page); | 187 | SetPageActive(page); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index cad5d528a6f0..30e56ee833f8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -531,7 +531,7 @@ redo: | |||
531 | * unevictable page on [in]active list. | 531 | * unevictable page on [in]active list. |
532 | * We know how to handle that. | 532 | * We know how to handle that. |
533 | */ | 533 | */ |
534 | lru = active + page_is_file_cache(page); | 534 | lru = active + page_lru_base_type(page); |
535 | lru_cache_add_lru(page, lru); | 535 | lru_cache_add_lru(page, lru); |
536 | } else { | 536 | } else { |
537 | /* | 537 | /* |
@@ -986,7 +986,7 @@ static unsigned long clear_active_flags(struct list_head *page_list, | |||
986 | struct page *page; | 986 | struct page *page; |
987 | 987 | ||
988 | list_for_each_entry(page, page_list, lru) { | 988 | list_for_each_entry(page, page_list, lru) { |
989 | lru = page_is_file_cache(page); | 989 | lru = page_lru_base_type(page); |
990 | if (PageActive(page)) { | 990 | if (PageActive(page)) { |
991 | lru += LRU_ACTIVE; | 991 | lru += LRU_ACTIVE; |
992 | ClearPageActive(page); | 992 | ClearPageActive(page); |
@@ -2652,7 +2652,7 @@ static void check_move_unevictable_page(struct page *page, struct zone *zone) | |||
2652 | retry: | 2652 | retry: |
2653 | ClearPageUnevictable(page); | 2653 | ClearPageUnevictable(page); |
2654 | if (page_evictable(page, NULL)) { | 2654 | if (page_evictable(page, NULL)) { |
2655 | enum lru_list l = LRU_INACTIVE_ANON + page_is_file_cache(page); | 2655 | enum lru_list l = page_lru_base_type(page); |
2656 | 2656 | ||
2657 | __dec_zone_state(zone, NR_UNEVICTABLE); | 2657 | __dec_zone_state(zone, NR_UNEVICTABLE); |
2658 | list_move(&page->lru, &zone->lru[l].list); | 2658 | list_move(&page->lru, &zone->lru[l].list); |