aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d12795cc7622..49d80814798b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -236,26 +236,12 @@ static struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont)
236 css); 236 css);
237} 237}
238 238
239static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) 239struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
240{ 240{
241 return container_of(task_subsys_state(p, mem_cgroup_subsys_id), 241 return container_of(task_subsys_state(p, mem_cgroup_subsys_id),
242 struct mem_cgroup, css); 242 struct mem_cgroup, css);
243} 243}
244 244
245void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p)
246{
247 struct mem_cgroup *mem;
248
249 mem = mem_cgroup_from_task(p);
250 css_get(&mem->css);
251 mm->mem_cgroup = mem;
252}
253
254void mm_free_cgroup(struct mm_struct *mm)
255{
256 css_put(&mm->mem_cgroup->css);
257}
258
259static inline int page_cgroup_locked(struct page *page) 245static inline int page_cgroup_locked(struct page *page)
260{ 246{
261 return bit_spin_is_locked(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); 247 return bit_spin_is_locked(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup);
@@ -476,6 +462,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
476 int zid = zone_idx(z); 462 int zid = zone_idx(z);
477 struct mem_cgroup_per_zone *mz; 463 struct mem_cgroup_per_zone *mz;
478 464
465 BUG_ON(!mem_cont);
479 mz = mem_cgroup_zoneinfo(mem_cont, nid, zid); 466 mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
480 if (active) 467 if (active)
481 src = &mz->active_list; 468 src = &mz->active_list;
@@ -574,7 +561,7 @@ retry:
574 mm = &init_mm; 561 mm = &init_mm;
575 562
576 rcu_read_lock(); 563 rcu_read_lock();
577 mem = rcu_dereference(mm->mem_cgroup); 564 mem = mem_cgroup_from_task(rcu_dereference(mm->owner));
578 /* 565 /*
579 * For every charge from the cgroup, increment reference count 566 * For every charge from the cgroup, increment reference count
580 */ 567 */
@@ -985,10 +972,9 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
985 struct mem_cgroup *mem; 972 struct mem_cgroup *mem;
986 int node; 973 int node;
987 974
988 if (unlikely((cont->parent) == NULL)) { 975 if (unlikely((cont->parent) == NULL))
989 mem = &init_mem_cgroup; 976 mem = &init_mem_cgroup;
990 init_mm.mem_cgroup = mem; 977 else
991 } else
992 mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); 978 mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL);
993 979
994 if (mem == NULL) 980 if (mem == NULL)
@@ -1067,10 +1053,6 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
1067 if (!thread_group_leader(p)) 1053 if (!thread_group_leader(p))
1068 goto out; 1054 goto out;
1069 1055
1070 css_get(&mem->css);
1071 rcu_assign_pointer(mm->mem_cgroup, mem);
1072 css_put(&old_mem->css);
1073
1074out: 1056out:
1075 mmput(mm); 1057 mmput(mm);
1076} 1058}