aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>2009-09-23 18:57:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-24 10:21:05 -0400
commit801460d0cf5c5288153b722565773059b0f44348 (patch)
treeff2542903572a546ac59e92f295e9a18e718afa0 /kernel
parent2fa4341074cd02fb39aa23410740764948755635 (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')
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c13
2 files changed, 7 insertions, 8 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 6c75ff83a8fe..5859f598c951 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -976,8 +976,6 @@ NORET_TYPE void do_exit(long code)
976 disassociate_ctty(1); 976 disassociate_ctty(1);
977 977
978 module_put(task_thread_info(tsk)->exec_domain->module); 978 module_put(task_thread_info(tsk)->exec_domain->module);
979 if (tsk->binfmt)
980 module_put(tsk->binfmt->module);
981 979
982 proc_exit_connector(tsk); 980 proc_exit_connector(tsk);
983 981
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
648free_pt: 653free_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
651fail_nomem: 658fail_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);
1332bad_fork_cleanup_put_domain:
1333 module_put(task_thread_info(p)->exec_domain->module); 1334 module_put(task_thread_info(p)->exec_domain->module);
1334bad_fork_cleanup_count: 1335bad_fork_cleanup_count:
1335 atomic_dec(&p->cred->user->processes); 1336 atomic_dec(&p->cred->user->processes);