aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mm_inline.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mm_inline.h')
-rw-r--r--include/linux/mm_inline.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 7fbb97267556..8835b877b8db 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -5,7 +5,7 @@
5 * page_is_file_cache - should the page be on a file LRU or anon LRU? 5 * page_is_file_cache - should the page be on a file LRU or anon LRU?
6 * @page: the page to test 6 * @page: the page to test
7 * 7 *
8 * Returns LRU_FILE if @page is page cache page backed by a regular filesystem, 8 * Returns 1 if @page is page cache page backed by a regular filesystem,
9 * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed. 9 * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
10 * Used by functions that manipulate the LRU lists, to sort a page 10 * Used by functions that manipulate the LRU lists, to sort a page
11 * onto the right LRU list. 11 * onto the right LRU list.
@@ -16,11 +16,7 @@
16 */ 16 */
17static inline int page_is_file_cache(struct page *page) 17static inline int page_is_file_cache(struct page *page)
18{ 18{
19 if (PageSwapBacked(page)) 19 return !PageSwapBacked(page);
20 return 0;
21
22 /* The page is page cache backed by a normal filesystem. */
23 return LRU_FILE;
24} 20}
25 21
26static inline void 22static inline void
@@ -39,21 +35,36 @@ del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
39 mem_cgroup_del_lru_list(page, l); 35 mem_cgroup_del_lru_list(page, l);
40} 36}
41 37
38/**
39 * page_lru_base_type - which LRU list type should a page be on?
40 * @page: the page to test
41 *
42 * Used for LRU list index arithmetic.
43 *
44 * Returns the base LRU type - file or anon - @page should be on.
45 */
46static inline enum lru_list page_lru_base_type(struct page *page)
47{
48 if (page_is_file_cache(page))
49 return LRU_INACTIVE_FILE;
50 return LRU_INACTIVE_ANON;
51}
52
42static inline void 53static inline void
43del_page_from_lru(struct zone *zone, struct page *page) 54del_page_from_lru(struct zone *zone, struct page *page)
44{ 55{
45 enum lru_list l = LRU_BASE; 56 enum lru_list l;
46 57
47 list_del(&page->lru); 58 list_del(&page->lru);
48 if (PageUnevictable(page)) { 59 if (PageUnevictable(page)) {
49 __ClearPageUnevictable(page); 60 __ClearPageUnevictable(page);
50 l = LRU_UNEVICTABLE; 61 l = LRU_UNEVICTABLE;
51 } else { 62 } else {
63 l = page_lru_base_type(page);
52 if (PageActive(page)) { 64 if (PageActive(page)) {
53 __ClearPageActive(page); 65 __ClearPageActive(page);
54 l += LRU_ACTIVE; 66 l += LRU_ACTIVE;
55 } 67 }
56 l += page_is_file_cache(page);
57 } 68 }
58 __dec_zone_state(zone, NR_LRU_BASE + l); 69 __dec_zone_state(zone, NR_LRU_BASE + l);
59 mem_cgroup_del_lru_list(page, l); 70 mem_cgroup_del_lru_list(page, l);
@@ -68,14 +79,14 @@ del_page_from_lru(struct zone *zone, struct page *page)
68 */ 79 */
69static inline enum lru_list page_lru(struct page *page) 80static inline enum lru_list page_lru(struct page *page)
70{ 81{
71 enum lru_list lru = LRU_BASE; 82 enum lru_list lru;
72 83
73 if (PageUnevictable(page)) 84 if (PageUnevictable(page))
74 lru = LRU_UNEVICTABLE; 85 lru = LRU_UNEVICTABLE;
75 else { 86 else {
87 lru = page_lru_base_type(page);
76 if (PageActive(page)) 88 if (PageActive(page))
77 lru += LRU_ACTIVE; 89 lru += LRU_ACTIVE;
78 lru += page_is_file_cache(page);
79 } 90 }
80 91
81 return lru; 92 return lru;