Skip to content

Commit

Permalink
bugfix for memory cgroup controller: avoid !PageLRU page in mem_cgrou…
Browse files Browse the repository at this point in the history
…p_isolate_pages

This patch makes mem_cgroup_isolate_pages() to be

  - ignore !PageLRU pages.
  - fixes the bug that isolation makes no progress if page_zone(page) != zone
    page once find. (just increment scan in this case.)

kswapd and memory migration removes a page from list when it handles
a page for reclaiming/migration.

Because __isolate_lru_page() doesn't moves page !PageLRU pages, it will
be safe to avoid touching !PageLRU() page and its page_cgroup.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Pavel Emelianov <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Kirill Korotaev <[email protected]>
Cc: Herbert Poetzl <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Vaidyanathan Srinivasan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hkamezawa authored and Linus Torvalds committed Feb 7, 2008
1 parent ae41be3 commit ff7283f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,26 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
unsigned long scan;
LIST_HEAD(pc_list);
struct list_head *src;
struct page_cgroup *pc;
struct page_cgroup *pc, *tmp;

if (active)
src = &mem_cont->active_list;
else
src = &mem_cont->inactive_list;

spin_lock(&mem_cont->lru_lock);
for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) {
pc = list_entry(src->prev, struct page_cgroup, lru);
scan = 0;
list_for_each_entry_safe_reverse(pc, tmp, src, lru) {
if (scan++ > nr_to_scan)
break;
page = pc->page;
VM_BUG_ON(!pc);

if (unlikely(!PageLRU(page))) {
scan--;
continue;
}

if (PageActive(page) && !active) {
__mem_cgroup_move_lists(pc, true);
scan--;
Expand Down

0 comments on commit ff7283f

Please sign in to comment.