Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | static inline void |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 2 | add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l) |
| 3 | { |
| 4 | list_add(&page->lru, &zone->lru[l].list); |
| 5 | __inc_zone_state(zone, NR_LRU_BASE + l); |
| 6 | } |
| 7 | |
| 8 | static inline void |
| 9 | del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l) |
| 10 | { |
| 11 | list_del(&page->lru); |
| 12 | __dec_zone_state(zone, NR_LRU_BASE + l); |
| 13 | } |
| 14 | |
| 15 | static inline void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | add_page_to_active_list(struct zone *zone, struct page *page) |
| 17 | { |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 18 | add_page_to_lru_list(zone, page, LRU_ACTIVE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static inline void |
| 22 | add_page_to_inactive_list(struct zone *zone, struct page *page) |
| 23 | { |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 24 | add_page_to_lru_list(zone, page, LRU_INACTIVE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | static inline void |
| 28 | del_page_from_active_list(struct zone *zone, struct page *page) |
| 29 | { |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 30 | del_page_from_lru_list(zone, page, LRU_ACTIVE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static inline void |
| 34 | del_page_from_inactive_list(struct zone *zone, struct page *page) |
| 35 | { |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 36 | del_page_from_lru_list(zone, page, LRU_INACTIVE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static inline void |
| 40 | del_page_from_lru(struct zone *zone, struct page *page) |
| 41 | { |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 42 | enum lru_list l = LRU_INACTIVE; |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | list_del(&page->lru); |
| 45 | if (PageActive(page)) { |
Nick Piggin | 6745391 | 2006-03-22 00:08:00 -0800 | [diff] [blame] | 46 | __ClearPageActive(page); |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 47 | l = LRU_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 49 | __dec_zone_state(zone, NR_LRU_BASE + l); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
Christoph Lameter | 21eac81 | 2006-01-08 01:00:45 -0800 | [diff] [blame] | 51 | |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame^] | 52 | /** |
| 53 | * page_lru - which LRU list should a page be on? |
| 54 | * @page: the page to test |
| 55 | * |
| 56 | * Returns the LRU list a page should be on, as an index |
| 57 | * into the array of LRU lists. |
| 58 | */ |
| 59 | static inline enum lru_list page_lru(struct page *page) |
| 60 | { |
| 61 | enum lru_list lru = LRU_BASE; |
| 62 | |
| 63 | if (PageActive(page)) |
| 64 | lru += LRU_ACTIVE; |
| 65 | |
| 66 | return lru; |
| 67 | } |