1 #ifndef LINUX_MM_INLINE_H
2 #define LINUX_MM_INLINE_H
5 * page_is_file_cache - should the page be on a file LRU or anon LRU?
6 * @page: the page to test
8 * Returns LRU_FILE 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.
10 * Used by functions that manipulate the LRU lists, to sort a page
11 * onto the right LRU list.
13 * We would like to get this info without a page flag, but the state
14 * needs to survive until the page is last deleted from the LRU, which
15 * could be as far down as __page_cache_release.
17 static inline int page_is_file_cache(struct page *page)
19 if (PageSwapBacked(page))
22 /* The page is page cache backed by a normal filesystem. */
27 add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
29 list_add(&page->lru, &zone->lru[l].list);
30 __inc_zone_state(zone, NR_LRU_BASE + l);
34 del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
37 __dec_zone_state(zone, NR_LRU_BASE + l);
41 add_page_to_inactive_anon_list(struct zone *zone, struct page *page)
43 add_page_to_lru_list(zone, page, LRU_INACTIVE_ANON);
47 add_page_to_active_anon_list(struct zone *zone, struct page *page)
49 add_page_to_lru_list(zone, page, LRU_ACTIVE_ANON);
53 add_page_to_inactive_file_list(struct zone *zone, struct page *page)
55 add_page_to_lru_list(zone, page, LRU_INACTIVE_FILE);
59 add_page_to_active_file_list(struct zone *zone, struct page *page)
61 add_page_to_lru_list(zone, page, LRU_ACTIVE_FILE);
65 del_page_from_inactive_anon_list(struct zone *zone, struct page *page)
67 del_page_from_lru_list(zone, page, LRU_INACTIVE_ANON);
71 del_page_from_active_anon_list(struct zone *zone, struct page *page)
73 del_page_from_lru_list(zone, page, LRU_ACTIVE_ANON);
77 del_page_from_inactive_file_list(struct zone *zone, struct page *page)
79 del_page_from_lru_list(zone, page, LRU_INACTIVE_FILE);
83 del_page_from_active_file_list(struct zone *zone, struct page *page)
85 del_page_from_lru_list(zone, page, LRU_INACTIVE_FILE);
89 del_page_from_lru(struct zone *zone, struct page *page)
91 enum lru_list l = LRU_BASE;
94 if (PageUnevictable(page)) {
95 __ClearPageUnevictable(page);
98 if (PageActive(page)) {
99 __ClearPageActive(page);
102 l += page_is_file_cache(page);
104 __dec_zone_state(zone, NR_LRU_BASE + l);
108 * page_lru - which LRU list should a page be on?
109 * @page: the page to test
111 * Returns the LRU list a page should be on, as an index
112 * into the array of LRU lists.
114 static inline enum lru_list page_lru(struct page *page)
116 enum lru_list lru = LRU_BASE;
118 if (PageUnevictable(page))
119 lru = LRU_UNEVICTABLE;
121 if (PageActive(page))
123 lru += page_is_file_cache(page);
130 * inactive_anon_is_low - check if anonymous pages need to be deactivated
131 * @zone: zone to check
133 * Returns true if the zone does not have enough inactive anon pages,
134 * meaning some active anon pages need to be deactivated.
136 static inline int inactive_anon_is_low(struct zone *zone)
138 unsigned long active, inactive;
140 active = zone_page_state(zone, NR_ACTIVE_ANON);
141 inactive = zone_page_state(zone, NR_INACTIVE_ANON);
143 if (inactive * zone->inactive_ratio < active)