diff options
| -rw-r--r-- | include/linux/memcontrol.h | 17 | ||||
| -rw-r--r-- | include/linux/mm_inline.h | 49 | ||||
| -rw-r--r-- | include/linux/mmzone.h | 26 | ||||
| -rw-r--r-- | mm/memcontrol.c | 115 | ||||
| -rw-r--r-- | mm/page_alloc.c | 9 | ||||
| -rw-r--r-- | mm/swap.c | 2 | ||||
| -rw-r--r-- | mm/vmscan.c | 120 | ||||
| -rw-r--r-- | mm/vmstat.c | 3 |
8 files changed, 171 insertions, 170 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index fdf3967e1397..a6ac0d491fe6 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
| @@ -69,10 +69,8 @@ extern void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, | |||
| 69 | extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, | 69 | extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, |
| 70 | int priority); | 70 | int priority); |
| 71 | 71 | ||
| 72 | extern long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, | 72 | extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone, |
| 73 | struct zone *zone, int priority); | 73 | int priority, enum lru_list lru); |
| 74 | extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, | ||
| 75 | struct zone *zone, int priority); | ||
| 76 | 74 | ||
| 77 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ | 75 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ |
| 78 | static inline void page_reset_bad_cgroup(struct page *page) | 76 | static inline void page_reset_bad_cgroup(struct page *page) |
| @@ -159,14 +157,9 @@ static inline void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, | |||
| 159 | { | 157 | { |
| 160 | } | 158 | } |
| 161 | 159 | ||
| 162 | static inline long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, | 160 | static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, |
| 163 | struct zone *zone, int priority) | 161 | struct zone *zone, int priority, |
| 164 | { | 162 | enum lru_list lru) |
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 168 | static inline long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, | ||
| 169 | struct zone *zone, int priority) | ||
| 170 | { | 163 | { |
| 171 | return 0; | 164 | return 0; |
| 172 | } | 165 | } |
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 895bc4e93039..2704729777ef 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h | |||
| @@ -1,40 +1,67 @@ | |||
| 1 | static inline void | 1 | static inline void |
| 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 | ||
| 2 | add_page_to_active_list(struct zone *zone, struct page *page) | 16 | add_page_to_active_list(struct zone *zone, struct page *page) |
| 3 | { | 17 | { |
| 4 | list_add(&page->lru, &zone->active_list); | 18 | add_page_to_lru_list(zone, page, LRU_ACTIVE); |
| 5 | __inc_zone_state(zone, NR_ACTIVE); | ||
| 6 | } | 19 | } |
| 7 | 20 | ||
| 8 | static inline void | 21 | static inline void |
| 9 | add_page_to_inactive_list(struct zone *zone, struct page *page) | 22 | add_page_to_inactive_list(struct zone *zone, struct page *page) |
| 10 | { | 23 | { |
| 11 | list_add(&page->lru, &zone->inactive_list); | 24 | add_page_to_lru_list(zone, page, LRU_INACTIVE); |
| 12 | __inc_zone_state(zone, NR_INACTIVE); | ||
| 13 | } | 25 | } |
| 14 | 26 | ||
| 15 | static inline void | 27 | static inline void |
| 16 | del_page_from_active_list(struct zone *zone, struct page *page) | 28 | del_page_from_active_list(struct zone *zone, struct page *page) |
| 17 | { | 29 | { |
| 18 | list_del(&page->lru); | 30 | del_page_from_lru_list(zone, page, LRU_ACTIVE); |
| 19 | __dec_zone_state(zone, NR_ACTIVE); | ||
| 20 | } | 31 | } |
| 21 | 32 | ||
| 22 | static inline void | 33 | static inline void |
| 23 | del_page_from_inactive_list(struct zone *zone, struct page *page) | 34 | del_page_from_inactive_list(struct zone *zone, struct page *page) |
| 24 | { | 35 | { |
| 25 | list_del(&page->lru); | 36 | del_page_from_lru_list(zone, page, LRU_INACTIVE); |
| 26 | __dec_zone_state(zone, NR_INACTIVE); | ||
| 27 | } | 37 | } |
| 28 | 38 | ||
| 29 | static inline void | 39 | static inline void |
| 30 | del_page_from_lru(struct zone *zone, struct page *page) | 40 | del_page_from_lru(struct zone *zone, struct page *page) |
| 31 | { | 41 | { |
| 42 | enum lru_list l = LRU_INACTIVE; | ||
| 43 | |||
| 32 | list_del(&page->lru); | 44 | list_del(&page->lru); |
| 33 | if (PageActive(page)) { | 45 | if (PageActive(page)) { |
| 34 | __ClearPageActive(page); | 46 | __ClearPageActive(page); |
| 35 | __dec_zone_state(zone, NR_ACTIVE); | 47 | l = LRU_ACTIVE; |
| 36 | } else { | ||
| 37 | __dec_zone_state(zone, NR_INACTIVE); | ||
| 38 | } | 48 | } |
| 49 | __dec_zone_state(zone, NR_LRU_BASE + l); | ||
| 39 | } | 50 | } |
| 40 | 51 | ||
| 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 | } | ||
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 428328a05fa1..156e18f3919b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
| @@ -81,8 +81,9 @@ struct zone_padding { | |||
| 81 | enum zone_stat_item { | 81 | enum zone_stat_item { |
| 82 | /* First 128 byte cacheline (assuming 64 bit words) */ | 82 | /* First 128 byte cacheline (assuming 64 bit words) */ |
| 83 | NR_FREE_PAGES, | 83 | NR_FREE_PAGES, |
| 84 | NR_INACTIVE, | 84 | NR_LRU_BASE, |
| 85 | NR_ACTIVE, | 85 | NR_INACTIVE = NR_LRU_BASE, /* must match order of LRU_[IN]ACTIVE */ |
| 86 | NR_ACTIVE, /* " " " " " */ | ||
| 86 | NR_ANON_PAGES, /* Mapped anonymous pages */ | 87 | NR_ANON_PAGES, /* Mapped anonymous pages */ |
| 87 | NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. | 88 | NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. |
| 88 | only modified from process context */ | 89 | only modified from process context */ |
| @@ -107,6 +108,19 @@ enum zone_stat_item { | |||
| 107 | #endif | 108 | #endif |
| 108 | NR_VM_ZONE_STAT_ITEMS }; | 109 | NR_VM_ZONE_STAT_ITEMS }; |
| 109 | 110 | ||
| 111 | enum lru_list { | ||
| 112 | LRU_BASE, | ||
| 113 | LRU_INACTIVE=LRU_BASE, /* must match order of NR_[IN]ACTIVE */ | ||
| 114 | LRU_ACTIVE, /* " " " " " */ | ||
| 115 | NR_LRU_LISTS }; | ||
| 116 | |||
| 117 | #define for_each_lru(l) for (l = 0; l < NR_LRU_LISTS; l++) | ||
| 118 | |||
| 119 | static inline int is_active_lru(enum lru_list l) | ||
| 120 | { | ||
| 121 | return (l == LRU_ACTIVE); | ||
| 122 | } | ||
| 123 | |||
| 110 | struct per_cpu_pages { | 124 | struct per_cpu_pages { |
| 111 | int count; /* number of pages in the list */ | 125 | int count; /* number of pages in the list */ |
| 112 | int high; /* high watermark, emptying needed */ | 126 | int high; /* high watermark, emptying needed */ |
| @@ -251,10 +265,10 @@ struct zone { | |||
| 251 | 265 | ||
| 252 | /* Fields commonly accessed by the page reclaim scanner */ | 266 | /* Fields commonly accessed by the page reclaim scanner */ |
| 253 | spinlock_t lru_lock; | 267 | spinlock_t lru_lock; |
| 254 | struct list_head active_list; | 268 | struct { |
| 255 | struct list_head inactive_list; | 269 | struct list_head list; |
| 256 | unsigned long nr_scan_active; | 270 | unsigned long nr_scan; |
| 257 | unsigned long nr_scan_inactive; | 271 | } lru[NR_LRU_LISTS]; |
| 258 | unsigned long pages_scanned; /* since last reclaim */ | 272 | unsigned long pages_scanned; /* since last reclaim */ |
| 259 | unsigned long flags; /* zone flags, see below */ | 273 | unsigned long flags; /* zone flags, see below */ |
| 260 | 274 | ||
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 36896f3eb7f5..c0cbd7790c51 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
| 33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
| 34 | #include <linux/vmalloc.h> | 34 | #include <linux/vmalloc.h> |
| 35 | #include <linux/mm_inline.h> | ||
| 35 | 36 | ||
| 36 | |||
