Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / mm_inline.h
blobc948350c378e93cb9144e9c17c52f3445e8f4a80
1 #ifndef LINUX_MM_INLINE_H
2 #define LINUX_MM_INLINE_H
4 /**
5 * page_is_file_cache - should the page be on a file LRU or anon LRU?
6 * @page: the page to test
8 * Returns LRU_FILE 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 if (PageSwapBacked(page))
20 return 0;
22 /* The page is page cache backed by a normal filesystem. */
23 return LRU_FILE;
26 static inline void
27 add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
29 list_add(&page->lru, &zone->lru[l].list);
30 __inc_zone_state(zone, NR_LRU_BASE + l);
33 static inline void
34 del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
36 list_del(&page->lru);
37 __dec_zone_state(zone, NR_LRU_BASE + l);
40 static inline void
41 del_page_from_lru(struct zone *zone, struct page *page)
43 enum lru_list l = LRU_BASE;
45 list_del(&page->lru);
46 if (PageUnevictable(page)) {
47 __ClearPageUnevictable(page);
48 l = LRU_UNEVICTABLE;
49 } else {
50 if (PageActive(page)) {
51 __ClearPageActive(page);
52 l += LRU_ACTIVE;
54 l += page_is_file_cache(page);
56 __dec_zone_state(zone, NR_LRU_BASE + l);
59 /**
60 * page_lru - which LRU list should a page be on?
61 * @page: the page to test
63 * Returns the LRU list a page should be on, as an index
64 * into the array of LRU lists.
66 static inline enum lru_list page_lru(struct page *page)
68 enum lru_list lru = LRU_BASE;
70 if (PageUnevictable(page))
71 lru = LRU_UNEVICTABLE;
72 else {
73 if (PageActive(page))
74 lru += LRU_ACTIVE;
75 lru += page_is_file_cache(page);
78 return lru;
81 /**
82 * inactive_anon_is_low - check if anonymous pages need to be deactivated
83 * @zone: zone to check
85 * Returns true if the zone does not have enough inactive anon pages,
86 * meaning some active anon pages need to be deactivated.
88 static inline int inactive_anon_is_low(struct zone *zone)
90 unsigned long active, inactive;
92 active = zone_page_state(zone, NR_ACTIVE_ANON);
93 inactive = zone_page_state(zone, NR_INACTIVE_ANON);
95 if (inactive * zone->inactive_ratio < active)
96 return 1;
98 return 0;
100 #endif