1
2#ifndef LINUX_MM_INLINE_H
3#define LINUX_MM_INLINE_H
4
5#include <linux/huge_mm.h>
6#include <linux/swap.h>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22static inline int page_is_file_lru(struct page *page)
23{
24 return !PageSwapBacked(page);
25}
26
27static __always_inline void update_lru_size(struct lruvec *lruvec,
28 enum lru_list lru, enum zone_type zid,
29 int nr_pages)
30{
31 struct pglist_data *pgdat = lruvec_pgdat(lruvec);
32
33 __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
34 __mod_zone_page_state(&pgdat->node_zones[zid],
35 NR_ZONE_LRU_BASE + lru, nr_pages);
36#ifdef CONFIG_MEMCG
37 mem_cgroup_update_lru_size(lruvec, lru, zid, nr_pages);
38#endif
39}
40
41
42
43
44
45static __always_inline void __clear_page_lru_flags(struct page *page)
46{
47 VM_BUG_ON_PAGE(!PageLRU(page), page);
48
49 __ClearPageLRU(page);
50
51
52 if (PageActive(page) && PageUnevictable(page))
53 return;
54
55 __ClearPageActive(page);
56 __ClearPageUnevictable(page);
57}
58
59
60
61
62
63
64
65
66static __always_inline enum lru_list page_lru(struct page *page)
67{
68 enum lru_list lru;
69
70 VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page);
71
72 if (PageUnevictable(page))
73 return LRU_UNEVICTABLE;
74
75 lru = page_is_file_lru(page) ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON;
76 if (PageActive(page))
77 lru += LRU_ACTIVE;
78
79 return lru;
80}
81
82static __always_inline void add_page_to_lru_list(struct page *page,
83 struct lruvec *lruvec)
84{
85 enum lru_list lru = page_lru(page);
86
87 update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page));
88 list_add(&page->lru, &lruvec->lists[lru]);
89}
90
91static __always_inline void add_page_to_lru_list_tail(struct page *page,
92 struct lruvec *lruvec)
93{
94 enum lru_list lru = page_lru(page);
95
96 update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page));
97 list_add_tail(&page->lru, &lruvec->lists[lru]);
98}
99
100static __always_inline void del_page_from_lru_list(struct page *page,
101 struct lruvec *lruvec)
102{
103 list_del(&page->lru);
104 update_lru_size(lruvec, page_lru(page), page_zonenum(page),
105 -thp_nr_pages(page));
106}
107#endif
108