diff options
author | Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> | 2009-09-23 18:57:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-24 10:21:05 -0400 |
commit | 801460d0cf5c5288153b722565773059b0f44348 (patch) | |
tree | ff2542903572a546ac59e92f295e9a18e718afa0 /kernel/fork.c | |
parent | 2fa4341074cd02fb39aa23410740764948755635 (diff) |
task_struct cleanup: move binfmt field to mm_struct
Because the binfmt is not different between threads in the same process,
it can be moved from task_struct to mm_struct. And binfmt moudle is
handled per mm_struct instead of task_struct.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index e49f181ba1ca..266c6af6ef1b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -518,6 +518,8 @@ void mmput(struct mm_struct *mm) | |||
518 | spin_unlock(&mmlist_lock); | 518 | spin_unlock(&mmlist_lock); |
519 | } | 519 | } |
520 | put_swap_token(mm); | 520 | put_swap_token(mm); |
521 | if (mm->binfmt) | ||
522 | module_put(mm->binfmt->module); | ||
521 | mmdrop(mm); | 523 | mmdrop(mm); |
522 | } | 524 | } |
523 | } | 525 | } |
@@ -643,9 +645,14 @@ struct mm_struct *dup_mm(struct task_struct *tsk) | |||
643 | mm->hiwater_rss = get_mm_rss(mm); | 645 | mm->hiwater_rss = get_mm_rss(mm); |
644 | mm->hiwater_vm = mm->total_vm; | 646 | mm->hiwater_vm = mm->total_vm; |
645 | 647 | ||
648 | if (mm->binfmt && !try_module_get(mm->binfmt->module)) | ||
649 | goto free_pt; | ||
650 | |||
646 | return mm; | 651 | return mm; |
647 | 652 | ||
648 | free_pt: | 653 | free_pt: |
654 | /* don't put binfmt in mmput, we haven't got module yet */ | ||
655 | mm->binfmt = NULL; | ||
649 | mmput(mm); | 656 | mmput(mm); |
650 | 657 | ||
651 | fail_nomem: | 658 | fail_nomem: |
@@ -1037,9 +1044,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1037 | if (!try_module_get(task_thread_info(p)->exec_domain->module)) | 1044 | if (!try_module_get(task_thread_info(p)->exec_domain->module)) |
1038 | goto bad_fork_cleanup_count; | 1045 | goto bad_fork_cleanup_count; |
1039 | 1046 | ||
1040 | if (p->binfmt && !try_module_get(p->binfmt->module)) | ||
1041 | goto bad_fork_cleanup_put_domain; | ||
1042 | |||
1043 | p->did_exec = 0; | 1047 | p->did_exec = 0; |
1044 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ | 1048 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ |
1045 | copy_flags(clone_flags, p); | 1049 | copy_flags(clone_flags, p); |
@@ -1327,9 +1331,6 @@ bad_fork_cleanup_cgroup: | |||
1327 | #endif | 1331 | #endif |
1328 | cgroup_exit(p, cgroup_callbacks_done); | 1332 | cgroup_exit(p, cgroup_callbacks_done); |
1329 | delayacct_tsk_free(p); | 1333 | delayacct_tsk_free(p); |
1330 | if (p->binfmt) | ||
1331 | module_put(p->binfmt->module); | ||
1332 | bad_fork_cleanup_put_domain: | ||
1333 | module_put(task_thread_info(p)->exec_domain->module); | 1334 | module_put(task_thread_info(p)->exec_domain->module); |
1334 | bad_fork_cleanup_count: | 1335 | bad_fork_cleanup_count: |
1335 | atomic_dec(&p->cred->user->processes); | 1336 | atomic_dec(&p->cred->user->processes); |