diff options
-rw-r--r-- | include/linux/memcontrol.h | 20 | ||||
-rw-r--r-- | mm/memcontrol.c | 23 |
2 files changed, 15 insertions, 28 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 70789df7dab4..8b1c4295848b 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -35,7 +35,8 @@ extern void mm_free_cgroup(struct mm_struct *mm); | |||
35 | extern struct page_cgroup *page_get_page_cgroup(struct page *page); | 35 | extern struct page_cgroup *page_get_page_cgroup(struct page *page); |
36 | extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm, | 36 | extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm, |
37 | gfp_t gfp_mask); | 37 | gfp_t gfp_mask); |
38 | extern void mem_cgroup_uncharge(struct page_cgroup *pc); | 38 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, |
39 | gfp_t gfp_mask); | ||
39 | extern void mem_cgroup_uncharge_page(struct page *page); | 40 | extern void mem_cgroup_uncharge_page(struct page *page); |
40 | extern void mem_cgroup_move_lists(struct page *page, bool active); | 41 | extern void mem_cgroup_move_lists(struct page *page, bool active); |
41 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | 42 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
@@ -45,8 +46,6 @@ extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | |||
45 | struct mem_cgroup *mem_cont, | 46 | struct mem_cgroup *mem_cont, |
46 | int active); | 47 | int active); |
47 | extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); | 48 | extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); |
48 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | ||
49 | gfp_t gfp_mask); | ||
50 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); | 49 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); |
51 | 50 | ||
52 | #define mm_match_cgroup(mm, cgroup) \ | 51 | #define mm_match_cgroup(mm, cgroup) \ |
@@ -92,14 +91,16 @@ static inline struct page_cgroup *page_get_page_cgroup(struct page *page) | |||
92 | return NULL; | 91 | return NULL; |
93 | } | 92 | } |
94 | 93 | ||
95 | static inline int mem_cgroup_charge(struct page *page, struct mm_struct *mm, | 94 | static inline int mem_cgroup_charge(struct page *page, |
96 | gfp_t gfp_mask) | 95 | struct mm_struct *mm, gfp_t gfp_mask) |
97 | { | 96 | { |
98 | return 0; | 97 | return 0; |
99 | } | 98 | } |
100 | 99 | ||
101 | static inline void mem_cgroup_uncharge(struct page_cgroup *pc) | 100 | static inline int mem_cgroup_cache_charge(struct page *page, |
101 | struct mm_struct *mm, gfp_t gfp_mask) | ||
102 | { | 102 | { |
103 | return 0; | ||
103 | } | 104 | } |
104 | 105 | ||
105 | static inline void mem_cgroup_uncharge_page(struct page *page) | 106 | static inline void mem_cgroup_uncharge_page(struct page *page) |
@@ -110,13 +111,6 @@ static inline void mem_cgroup_move_lists(struct page *page, bool active) | |||
110 | { | 111 | { |
111 | } | 112 | } |
112 | 113 | ||
113 | static inline int mem_cgroup_cache_charge(struct page *page, | ||
114 | struct mm_struct *mm, | ||
115 | gfp_t gfp_mask) | ||
116 | { | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) | 114 | static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) |
121 | { | 115 | { |
122 | return 1; | 116 | return 1; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 83ba13ad31e1..1333d25163bb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -697,20 +697,22 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | |||
697 | 697 | ||
698 | /* | 698 | /* |
699 | * Uncharging is always a welcome operation, we never complain, simply | 699 | * Uncharging is always a welcome operation, we never complain, simply |
700 | * uncharge. This routine should be called with lock_page_cgroup held | 700 | * uncharge. |
701 | */ | 701 | */ |
702 | void mem_cgroup_uncharge(struct page_cgroup *pc) | 702 | void mem_cgroup_uncharge_page(struct page *page) |
703 | { | 703 | { |
704 | struct page_cgroup *pc; | ||
704 | struct mem_cgroup *mem; | 705 | struct mem_cgroup *mem; |
705 | struct mem_cgroup_per_zone *mz; | 706 | struct mem_cgroup_per_zone *mz; |
706 | struct page *page; | ||
707 | unsigned long flags; | 707 | unsigned long flags; |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * Check if our page_cgroup is valid | 710 | * Check if our page_cgroup is valid |
711 | */ | 711 | */ |
712 | lock_page_cgroup(page); | ||
713 | pc = page_get_page_cgroup(page); | ||
712 | if (!pc) | 714 | if (!pc) |
713 | return; | 715 | goto unlock; |
714 | 716 | ||
715 | if (atomic_dec_and_test(&pc->ref_cnt)) { | 717 | if (atomic_dec_and_test(&pc->ref_cnt)) { |
716 | page = pc->page; | 718 | page = pc->page; |
@@ -731,12 +733,8 @@ void mem_cgroup_uncharge(struct page_cgroup *pc) | |||
731 | } | 733 | } |
732 | lock_page_cgroup(page); | 734 | lock_page_cgroup(page); |
733 | } | 735 | } |
734 | } | ||
735 | 736 | ||
736 | void mem_cgroup_uncharge_page(struct page *page) | 737 | unlock: |
737 | { | ||
738 | lock_page_cgroup(page); | ||
739 | mem_cgroup_uncharge(page_get_page_cgroup(page)); | ||
740 | unlock_page_cgroup(page); | 738 | unlock_page_cgroup(page); |
741 | } | 739 | } |
742 | 740 | ||
@@ -759,12 +757,7 @@ int mem_cgroup_prepare_migration(struct page *page) | |||
759 | 757 | ||
760 | void mem_cgroup_end_migration(struct page *page) | 758 | void mem_cgroup_end_migration(struct page *page) |
761 | { | 759 | { |
762 | struct page_cgroup *pc; | 760 | mem_cgroup_uncharge_page(page); |
763 | |||
764 | lock_page_cgroup(page); | ||
765 | pc = page_get_page_cgroup(page); | ||
766 | mem_cgroup_uncharge(pc); | ||
767 | unlock_page_cgroup(page); | ||
768 | } | 761 | } |
769 | /* | 762 | /* |
770 | * We know both *page* and *newpage* are now not-on-LRU and Pg_locked. | 763 | * We know both *page* and *newpage* are now not-on-LRU and Pg_locked. |