define page_file_cache() function
[safe/jmp/linux-2.6] / include / linux / mm_inline.h
1 #ifndef LINUX_MM_INLINE_H
2 #define LINUX_MM_INLINE_H
3
4 /**
5  * page_is_file_cache - should the page be on a file LRU or anon LRU?
6  * @page: the page to test
7  *
8  * Returns !0 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.
12  *
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.
16  */
17 static inline int page_is_file_cache(struct page *page)
18 {
19         if (PageSwapBacked(page))
20                 return 0;
21
22         /* The page is page cache backed by a normal filesystem. */
23         return 1;
24 }
25
26 static inline void
27 add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
28 {
29         list_add(&page->lru, &zone->lru[l].list);
30         __inc_zone_state(zone, NR_LRU_BASE + l);
31 }
32
33 static inline void
34 del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
35 {
36         list_del(&page->lru);
37         __dec_zone_state(zone, NR_LRU_BASE + l);
38 }
39
40 static inline void
41 add_page_to_active_list(struct zone *zone, struct page *page)
42 {
43         add_page_to_lru_list(zone, page, LRU_ACTIVE);
44 }
45
46 static inline void
47 add_page_to_inactive_list(struct zone *zone, struct page *page)
48 {
49         add_page_to_lru_list(zone, page, LRU_INACTIVE);
50 }
51
52 static inline void
53 del_page_from_active_list(struct zone *zone, struct page *page)
54 {
55         del_page_from_lru_list(zone, page, LRU_ACTIVE);
56 }
57
58 static inline void
59 del_page_from_inactive_list(struct zone *zone, struct page *page)
60 {
61         del_page_from_lru_list(zone, page, LRU_INACTIVE);
62 }
63
64 static inline void
65 del_page_from_lru(struct zone *zone, struct page *page)
66 {
67         enum lru_list l = LRU_INACTIVE;
68
69         list_del(&page->lru);
70         if (PageActive(page)) {
71                 __ClearPageActive(page);
72                 l = LRU_ACTIVE;
73         }
74         __dec_zone_state(zone, NR_LRU_BASE + l);
75 }
76
77 /**
78  * page_lru - which LRU list should a page be on?
79  * @page: the page to test
80  *
81  * Returns the LRU list a page should be on, as an index
82  * into the array of LRU lists.
83  */
84 static inline enum lru_list page_lru(struct page *page)
85 {
86         enum lru_list lru = LRU_BASE;
87
88         if (PageActive(page))
89                 lru += LRU_ACTIVE;
90
91         return lru;
92 }
93
94 #endif