diff options
Diffstat (limited to 'mm/rmap.c')
-rw-r--r-- | mm/rmap.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/rcupdate.h> | 48 | #include <linux/rcupdate.h> |
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/kallsyms.h> | 50 | #include <linux/kallsyms.h> |
51 | #include <linux/memcontrol.h> | ||
51 | 52 | ||
52 | #include <asm/tlbflush.h> | 53 | #include <asm/tlbflush.h> |
53 | 54 | ||
@@ -554,8 +555,14 @@ void page_add_anon_rmap(struct page *page, | |||
554 | VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end); | 555 | VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end); |
555 | if (atomic_inc_and_test(&page->_mapcount)) | 556 | if (atomic_inc_and_test(&page->_mapcount)) |
556 | __page_set_anon_rmap(page, vma, address); | 557 | __page_set_anon_rmap(page, vma, address); |
557 | else | 558 | else { |
558 | __page_check_anon_rmap(page, vma, address); | 559 | __page_check_anon_rmap(page, vma, address); |
560 | /* | ||
561 | * We unconditionally charged during prepare, we uncharge here | ||
562 | * This takes care of balancing the reference counts | ||
563 | */ | ||
564 | mem_cgroup_uncharge_page(page); | ||
565 | } | ||
559 | } | 566 | } |
560 | 567 | ||
561 | /* | 568 | /* |
@@ -586,6 +593,12 @@ void page_add_file_rmap(struct page *page) | |||
586 | { | 593 | { |
587 | if (atomic_inc_and_test(&page->_mapcount)) | 594 | if (atomic_inc_and_test(&page->_mapcount)) |
588 | __inc_zone_page_state(page, NR_FILE_MAPPED); | 595 | __inc_zone_page_state(page, NR_FILE_MAPPED); |
596 | else | ||
597 | /* | ||
598 | * We unconditionally charged during prepare, we uncharge here | ||
599 | * This takes care of balancing the reference counts | ||
600 | */ | ||
601 | mem_cgroup_uncharge_page(page); | ||
589 | } | 602 | } |
590 | 603 | ||
591 | #ifdef CONFIG_DEBUG_VM | 604 | #ifdef CONFIG_DEBUG_VM |
@@ -646,6 +659,8 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma) | |||
646 | page_clear_dirty(page); | 659 | page_clear_dirty(page); |
647 | set_page_dirty(page); | 660 | set_page_dirty(page); |
648 | } | 661 | } |
662 | mem_cgroup_uncharge_page(page); | ||
663 | |||
649 | __dec_zone_page_state(page, | 664 | __dec_zone_page_state(page, |
650 | PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED); | 665 | PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED); |
651 | } | 666 | } |