Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mm_inline.h
Go to the documentation of this file.
1 #ifndef LINUX_MM_INLINE_H
2 #define LINUX_MM_INLINE_H
3 
4 #include <linux/huge_mm.h>
5 
19 static inline int page_is_file_cache(struct page *page)
20 {
21  return !PageSwapBacked(page);
22 }
23 
24 static __always_inline void add_page_to_lru_list(struct page *page,
25  struct lruvec *lruvec, enum lru_list lru)
26 {
27  int nr_pages = hpage_nr_pages(page);
28  mem_cgroup_update_lru_size(lruvec, lru, nr_pages);
29  list_add(&page->lru, &lruvec->lists[lru]);
30  __mod_zone_page_state(lruvec_zone(lruvec), NR_LRU_BASE + lru, nr_pages);
31 }
32 
33 static __always_inline void del_page_from_lru_list(struct page *page,
34  struct lruvec *lruvec, enum lru_list lru)
35 {
36  int nr_pages = hpage_nr_pages(page);
37  mem_cgroup_update_lru_size(lruvec, lru, -nr_pages);
38  list_del(&page->lru);
39  __mod_zone_page_state(lruvec_zone(lruvec), NR_LRU_BASE + lru, -nr_pages);
40 }
41 
50 static inline enum lru_list page_lru_base_type(struct page *page)
51 {
52  if (page_is_file_cache(page))
53  return LRU_INACTIVE_FILE;
54  return LRU_INACTIVE_ANON;
55 }
56 
64 static __always_inline enum lru_list page_off_lru(struct page *page)
65 {
66  enum lru_list lru;
67 
68  if (PageUnevictable(page)) {
69  __ClearPageUnevictable(page);
70  lru = LRU_UNEVICTABLE;
71  } else {
72  lru = page_lru_base_type(page);
73  if (PageActive(page)) {
74  __ClearPageActive(page);
75  lru += LRU_ACTIVE;
76  }
77  }
78  return lru;
79 }
80 
88 static __always_inline enum lru_list page_lru(struct page *page)
89 {
90  enum lru_list lru;
91 
92  if (PageUnevictable(page))
93  lru = LRU_UNEVICTABLE;
94  else {
95  lru = page_lru_base_type(page);
96  if (PageActive(page))
97  lru += LRU_ACTIVE;
98  }
99  return lru;
100 }
101 
102 #endif