diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 128f45c16fa6..e8493fb2d69e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -250,7 +250,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | |||
250 | unsigned long scan; | 250 | unsigned long scan; |
251 | LIST_HEAD(pc_list); | 251 | LIST_HEAD(pc_list); |
252 | struct list_head *src; | 252 | struct list_head *src; |
253 | struct page_cgroup *pc; | 253 | struct page_cgroup *pc, *tmp; |
254 | 254 | ||
255 | if (active) | 255 | if (active) |
256 | src = &mem_cont->active_list; | 256 | src = &mem_cont->active_list; |
@@ -258,11 +258,18 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | |||
258 | src = &mem_cont->inactive_list; | 258 | src = &mem_cont->inactive_list; |
259 | 259 | ||
260 | spin_lock(&mem_cont->lru_lock); | 260 | spin_lock(&mem_cont->lru_lock); |
261 | for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) { | 261 | scan = 0; |
262 | pc = list_entry(src->prev, struct page_cgroup, lru); | 262 | list_for_each_entry_safe_reverse(pc, tmp, src, lru) { |
263 | if (scan++ > nr_to_scan) | ||
264 | break; | ||
263 | page = pc->page; | 265 | page = pc->page; |
264 | VM_BUG_ON(!pc); | 266 | VM_BUG_ON(!pc); |
265 | 267 | ||
268 | if (unlikely(!PageLRU(page))) { | ||
269 | scan--; | ||
270 | continue; | ||
271 | } | ||
272 | |||
266 | if (PageActive(page) && !active) { | 273 | if (PageActive(page) && !active) { |
267 | __mem_cgroup_move_lists(pc, true); | 274 | __mem_cgroup_move_lists(pc, true); |
268 | scan--; | 275 | scan--; |