1 #ifndef LINUX_MM_INLINE_H
2 #define LINUX_MM_INLINE_H
4 #include <linux/huge_mm.h>
7 * page_is_file_cache - should the page be on a file LRU or anon LRU?
8 * @page: the page to test
10 * Returns 1 if @page is page cache page backed by a regular filesystem,
11 * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
12 * Used by functions that manipulate the LRU lists, to sort a page
13 * onto the right LRU list.
15 * We would like to get this info without a page flag, but the state
16 * needs to survive until the page is last deleted from the LRU, which
17 * could be as far down as __page_cache_release.
19 static inline int page_is_file_cache(struct page *page)
21 return !PageSwapBacked(page);
25 add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list lru)
27 struct lruvec *lruvec;
29 lruvec = mem_cgroup_lru_add_list(zone, page, lru);
30 list_add(&page->lru, &lruvec->lists[lru]);
31 __mod_zone_page_state(zone, NR_LRU_BASE + lru, hpage_nr_pages(page));
35 del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list lru)
37 mem_cgroup_lru_del_list(page, lru);
39 __mod_zone_page_state(zone, NR_LRU_BASE + lru, -hpage_nr_pages(page));
43 * page_lru_base_type - which LRU list type should a page be on?
44 * @page: the page to test
46 * Used for LRU list index arithmetic.
48 * Returns the base LRU type - file or anon - @page should be on.
50 static inline enum lru_list page_lru_base_type(struct page *page)
52 if (page_is_file_cache(page))
53 return LRU_INACTIVE_FILE;
54 return LRU_INACTIVE_ANON;
58 * page_off_lru - which LRU list was page on? clearing its lru flags.
59 * @page: the page to test
61 * Returns the LRU list a page was on, as an index into the array of LRU
62 * lists; and clears its Unevictable or Active flags, ready for freeing.
64 static inline enum lru_list page_off_lru(struct page *page)
68 if (PageUnevictable(page)) {
69 __ClearPageUnevictable(page);
70 lru = LRU_UNEVICTABLE;
72 lru = page_lru_base_type(page);
73 if (PageActive(page)) {
74 __ClearPageActive(page);
82 * page_lru - which LRU list should a page be on?
83 * @page: the page to test
85 * Returns the LRU list a page should be on, as an index
86 * into the array of LRU lists.
88 static inline enum lru_list page_lru(struct page *page)
92 if (PageUnevictable(page))
93 lru = LRU_UNEVICTABLE;
95 lru = page_lru_base_type(page);