blob: 2704729777eff9049c1758914f375ae29a8f582d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001static inline void
Christoph Lameterb69408e2008-10-18 20:26:14 -07002add_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
8static inline void
9del_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
15static inline void
Linus Torvalds1da177e2005-04-16 15:20:36 -070016add_page_to_active_list(struct zone *zone, struct page *page)
17{
Christoph Lameterb69408e2008-10-18 20:26:14 -070018 add_page_to_lru_list(zone, page, LRU_ACTIVE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019}
20
21static inline void
22add_page_to_inactive_list(struct zone *zone, struct page *page)
23{
Christoph Lameterb69408e2008-10-18 20:26:14 -070024 add_page_to_lru_list(zone, page, LRU_INACTIVE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025}
26
27static inline void
28del_page_from_active_list(struct zone *zone, struct page *page)
29{
Christoph Lameterb69408e2008-10-18 20:26:14 -070030 del_page_from_lru_list(zone, page, LRU_ACTIVE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
33static inline void
34del_page_from_inactive_list(struct zone *zone, struct page *page)
35{
Christoph Lameterb69408e2008-10-18 20:26:14 -070036 del_page_from_lru_list(zone, page, LRU_INACTIVE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
39static inline void
40del_page_from_lru(struct zone *zone, struct page *page)
41{
Christoph Lameterb69408e2008-10-18 20:26:14 -070042 enum lru_list l = LRU_INACTIVE;
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 list_del(&page->lru);
45 if (PageActive(page)) {
Nick Piggin67453912006-03-22 00:08:00 -080046 __ClearPageActive(page);
Christoph Lameterb69408e2008-10-18 20:26:14 -070047 l = LRU_ACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 }
Christoph Lameterb69408e2008-10-18 20:26:14 -070049 __dec_zone_state(zone, NR_LRU_BASE + l);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
Christoph Lameter21eac812006-01-08 01:00:45 -080051
Christoph Lameterb69408e2008-10-18 20:26:14 -070052/**
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 */
59static 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}