aboutsummaryrefslogtreecommitdiffstats
path: root/mm/migrate.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-26 11:48:49 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-26 11:48:49 -0400
commitc3cc99ff5d24e2eeaf7ec2032e720681916990e3 (patch)
treec3e74171bbbd2adde9d60b9db1c440415c8d2831 /mm/migrate.c
parent38ffbe66d59051fd9cfcfc8545f164700e2fa3bc (diff)
parent024e8ac04453b3525448c31ef39848cf675ba6db (diff)
Merge branch 'linus' into x86/xen
Diffstat (limited to 'mm/migrate.c')
-rw-r--r--mm/migrate.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/mm/migrate.c b/mm/migrate.c
index 55bd355d170d..d8c65a65c61d 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -30,6 +30,7 @@
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <linux/security.h> 31#include <linux/security.h>
32#include <linux/memcontrol.h> 32#include <linux/memcontrol.h>
33#include <linux/syscalls.h>
33 34
34#include "internal.h" 35#include "internal.h"
35 36
@@ -357,6 +358,9 @@ static int migrate_page_move_mapping(struct address_space *mapping,
357 __inc_zone_page_state(newpage, NR_FILE_PAGES); 358 __inc_zone_page_state(newpage, NR_FILE_PAGES);
358 359
359 write_unlock_irq(&mapping->tree_lock); 360 write_unlock_irq(&mapping->tree_lock);
361 if (!PageSwapCache(newpage)) {
362 mem_cgroup_uncharge_cache_page(page);
363 }
360 364
361 return 0; 365 return 0;
362} 366}
@@ -610,7 +614,6 @@ static int move_to_new_page(struct page *newpage, struct page *page)
610 rc = fallback_migrate_page(mapping, newpage, page); 614 rc = fallback_migrate_page(mapping, newpage, page);
611 615
612 if (!rc) { 616 if (!rc) {
613 mem_cgroup_page_migration(page, newpage);
614 remove_migration_ptes(page, newpage); 617 remove_migration_ptes(page, newpage);
615 } else 618 } else
616 newpage->mapping = NULL; 619 newpage->mapping = NULL;
@@ -640,6 +643,14 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
640 /* page was freed from under us. So we are done. */ 643 /* page was freed from under us. So we are done. */
641 goto move_newpage; 644 goto move_newpage;
642 645
646 charge = mem_cgroup_prepare_migration(page, newpage);
647 if (charge == -ENOMEM) {
648 rc = -ENOMEM;
649 goto move_newpage;
650 }
651 /* prepare cgroup just returns 0 or -ENOMEM */
652 BUG_ON(charge);
653
643 rc = -EAGAIN; 654 rc = -EAGAIN;
644 if (TestSetPageLocked(page)) { 655 if (TestSetPageLocked(page)) {
645 if (!force) 656 if (!force)
@@ -691,19 +702,14 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
691 goto rcu_unlock; 702 goto rcu_unlock;
692 } 703 }
693 704
694 charge = mem_cgroup_prepare_migration(page);
695 /* Establish migration ptes or remove ptes */ 705 /* Establish migration ptes or remove ptes */
696 try_to_unmap(page, 1); 706 try_to_unmap(page, 1);
697 707
698 if (!page_mapped(page)) 708 if (!page_mapped(page))
699 rc = move_to_new_page(newpage, page); 709 rc = move_to_new_page(newpage, page);
700 710
701 if (rc) { 711 if (rc)
702 remove_migration_ptes(page, page); 712 remove_migration_ptes(page, page);
703 if (charge)
704 mem_cgroup_end_migration(page);
705 } else if (charge)
706 mem_cgroup_end_migration(newpage);
707rcu_unlock: 713rcu_unlock:
708 if (rcu_locked) 714 if (rcu_locked)
709 rcu_read_unlock(); 715 rcu_read_unlock();
@@ -724,6 +730,8 @@ unlock:
724 } 730 }
725 731
726move_newpage: 732move_newpage:
733 if (!charge)
734 mem_cgroup_end_migration(newpage);
727 /* 735 /*
728 * Move the new page to the LRU. If migration was not successful 736 * Move the new page to the LRU. If migration was not successful
729 * then this will free the page. 737 * then this will free the page.
@@ -1070,7 +1078,6 @@ out2:
1070 mmput(mm); 1078 mmput(mm);
1071 return err; 1079 return err;
1072} 1080}
1073#endif
1074 1081
1075/* 1082/*
1076 * Call migration functions in the vma_ops that may prepare 1083 * Call migration functions in the vma_ops that may prepare
@@ -1092,3 +1099,4 @@ int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
1092 } 1099 }
1093 return err; 1100 return err;
1094} 1101}
1102#endif