diff options
author | Pavel Emelianov <xemul@openvz.org> | 2008-02-07 03:13:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:18 -0500 |
commit | 78fb74669e80883323391090e4d26d17fe29488f (patch) | |
tree | 9154b703510415ae87bdae8750c1054e79710c61 /kernel | |
parent | 8cdea7c05454260c0d4d83503949c358eb131d17 (diff) |
Memory controller: accounting setup
Basic setup routines, the mm_struct has a pointer to the cgroup that
it belongs to and the the page has a page_cgroup associated with it.
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Kirill Korotaev <dev@sw.ru>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 3995297567a9..b2ef8e4fad70 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/ptrace.h> | 40 | #include <linux/ptrace.h> |
41 | #include <linux/mount.h> | 41 | #include <linux/mount.h> |
42 | #include <linux/audit.h> | 42 | #include <linux/audit.h> |
43 | #include <linux/memcontrol.h> | ||
43 | #include <linux/profile.h> | 44 | #include <linux/profile.h> |
44 | #include <linux/rmap.h> | 45 | #include <linux/rmap.h> |
45 | #include <linux/acct.h> | 46 | #include <linux/acct.h> |
@@ -340,7 +341,7 @@ __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock); | |||
340 | 341 | ||
341 | #include <linux/init_task.h> | 342 | #include <linux/init_task.h> |
342 | 343 | ||
343 | static struct mm_struct * mm_init(struct mm_struct * mm) | 344 | static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) |
344 | { | 345 | { |
345 | atomic_set(&mm->mm_users, 1); | 346 | atomic_set(&mm->mm_users, 1); |
346 | atomic_set(&mm->mm_count, 1); | 347 | atomic_set(&mm->mm_count, 1); |
@@ -357,11 +358,14 @@ static struct mm_struct * mm_init(struct mm_struct * mm) | |||
357 | mm->ioctx_list = NULL; | 358 | mm->ioctx_list = NULL; |
358 | mm->free_area_cache = TASK_UNMAPPED_BASE; | 359 | mm->free_area_cache = TASK_UNMAPPED_BASE; |
359 | mm->cached_hole_size = ~0UL; | 360 | mm->cached_hole_size = ~0UL; |
361 | mm_init_cgroup(mm, p); | ||
360 | 362 | ||
361 | if (likely(!mm_alloc_pgd(mm))) { | 363 | if (likely(!mm_alloc_pgd(mm))) { |
362 | mm->def_flags = 0; | 364 | mm->def_flags = 0; |
363 | return mm; | 365 | return mm; |
364 | } | 366 | } |
367 | |||
368 | mm_free_cgroup(mm); | ||
365 | free_mm(mm); | 369 | free_mm(mm); |
366 | return NULL; | 370 | return NULL; |
367 | } | 371 | } |
@@ -376,7 +380,7 @@ struct mm_struct * mm_alloc(void) | |||
376 | mm = allocate_mm(); | 380 | mm = allocate_mm(); |
377 | if (mm) { | 381 | if (mm) { |
378 | memset(mm, 0, sizeof(*mm)); | 382 | memset(mm, 0, sizeof(*mm)); |
379 | mm = mm_init(mm); | 383 | mm = mm_init(mm, current); |
380 | } | 384 | } |
381 | return mm; | 385 | return mm; |
382 | } | 386 | } |
@@ -390,6 +394,7 @@ void fastcall __mmdrop(struct mm_struct *mm) | |||
390 | { | 394 | { |
391 | BUG_ON(mm == &init_mm); | 395 | BUG_ON(mm == &init_mm); |
392 | mm_free_pgd(mm); | 396 | mm_free_pgd(mm); |
397 | mm_free_cgroup(mm); | ||
393 | destroy_context(mm); | 398 | destroy_context(mm); |
394 | free_mm(mm); | 399 | free_mm(mm); |
395 | } | 400 | } |
@@ -511,7 +516,7 @@ static struct mm_struct *dup_mm(struct task_struct *tsk) | |||
511 | mm->token_priority = 0; | 516 | mm->token_priority = 0; |
512 | mm->last_interval = 0; | 517 | mm->last_interval = 0; |
513 | 518 | ||
514 | if (!mm_init(mm)) | 519 | if (!mm_init(mm, tsk)) |
515 | goto fail_nomem; | 520 | goto fail_nomem; |
516 | 521 | ||
517 | if (init_new_context(tsk, mm)) | 522 | if (init_new_context(tsk, mm)) |