]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/mm_inline.h
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 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.
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 return !PageSwapBacked(page
);
23 __add_page_to_lru_list(struct zone
*zone
, struct page
*page
, enum lru_list l
,
24 struct list_head
*head
)
26 list_add(&page
->lru
, head
);
27 __inc_zone_state(zone
, NR_LRU_BASE
+ l
);
28 mem_cgroup_add_lru_list(page
, l
);
32 add_page_to_lru_list(struct zone
*zone
, struct page
*page
, enum lru_list l
)
34 __add_page_to_lru_list(zone
, page
, l
, &zone
->lru
[l
].list
);
38 del_page_from_lru_list(struct zone
*zone
, struct page
*page
, enum lru_list l
)
41 __dec_zone_state(zone
, NR_LRU_BASE
+ l
);
42 mem_cgroup_del_lru_list(page
, l
);
46 * page_lru_base_type - which LRU list type should a page be on?
47 * @page: the page to test
49 * Used for LRU list index arithmetic.
51 * Returns the base LRU type - file or anon - @page should be on.
53 static inline enum lru_list
page_lru_base_type(struct page
*page
)
55 if (page_is_file_cache(page
))
56 return LRU_INACTIVE_FILE
;
57 return LRU_INACTIVE_ANON
;
61 del_page_from_lru(struct zone
*zone
, struct page
*page
)
66 if (PageUnevictable(page
)) {
67 __ClearPageUnevictable(page
);
70 l
= page_lru_base_type(page
);
71 if (PageActive(page
)) {
72 __ClearPageActive(page
);
76 __dec_zone_state(zone
, NR_LRU_BASE
+ l
);
77 mem_cgroup_del_lru_list(page
, l
);
81 * page_lru - which LRU list should a page be on?
82 * @page: the page to test
84 * Returns the LRU list a page should be on, as an index
85 * into the array of LRU lists.
87 static inline enum lru_list
page_lru(struct page
*page
)
91 if (PageUnevictable(page
))
92 lru
= LRU_UNEVICTABLE
;
94 lru
= page_lru_base_type(page
);