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);
31 mem_cgroup_add_lru_list(page, l);
35 del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
38 __dec_zone_state(zone, NR_LRU_BASE + l);
39 mem_cgroup_del_lru_list(page, l);
43 del_page_from_lru(struct zone *zone, struct page *page)
45 enum lru_list l = LRU_BASE;
48 if (PageUnevictable(page)) {
49 __ClearPageUnevictable(page);
52 if (PageActive(page)) {
53 __ClearPageActive(page);
56 l += page_is_file_cache(page);
58 __dec_zone_state(zone, NR_LRU_BASE + l);
59 mem_cgroup_del_lru_list(page, l);
63 * page_lru - which LRU list should a page be on?
64 * @page: the page to test
66 * Returns the LRU list a page should be on, as an index
67 * into the array of LRU lists.
69 static inline enum lru_list page_lru(struct page *page)
71 enum lru_list lru = LRU_BASE;
73 if (PageUnevictable(page))
74 lru = LRU_UNEVICTABLE;
78 lru += page_is_file_cache(page);