Commit 4272948a authored by Hiroshi Shimamoto's avatar Hiroshi Shimamoto Committed by James Toy

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: default avatarHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: default avatarRoland McGrath <roland@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent da7de456
...@@ -1399,10 +1399,12 @@ out_ret: ...@@ -1399,10 +1399,12 @@ out_ret:
void set_binfmt(struct linux_binfmt *new) void set_binfmt(struct linux_binfmt *new)
{ {
if (current->binfmt) struct mm_struct *mm = current->mm;
module_put(current->binfmt->module);
if (mm->binfmt)
module_put(mm->binfmt->module);
current->binfmt = new; mm->binfmt = new;
if (new) if (new)
__module_get(new->module); __module_get(new->module);
} }
...@@ -1772,7 +1774,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) ...@@ -1772,7 +1774,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
audit_core_dumps(signr); audit_core_dumps(signr);
binfmt = current->binfmt; binfmt = mm->binfmt;
if (!binfmt || !binfmt->core_dump) if (!binfmt || !binfmt->core_dump)
goto fail; goto fail;
......
...@@ -240,6 +240,8 @@ struct mm_struct { ...@@ -240,6 +240,8 @@ struct mm_struct {
unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */ unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
struct linux_binfmt *binfmt;
cpumask_t cpu_vm_mask; cpumask_t cpu_vm_mask;
/* Architecture-specific MM context */ /* Architecture-specific MM context */
......
...@@ -1276,7 +1276,6 @@ struct task_struct { ...@@ -1276,7 +1276,6 @@ struct task_struct {
struct mm_struct *mm, *active_mm; struct mm_struct *mm, *active_mm;
/* task state */ /* task state */
struct linux_binfmt *binfmt;
int exit_state; int exit_state;
int exit_code, exit_signal; int exit_code, exit_signal;
int pdeath_signal; /* The signal sent when the parent dies */ int pdeath_signal; /* The signal sent when the parent dies */
......
...@@ -977,8 +977,6 @@ NORET_TYPE void do_exit(long code) ...@@ -977,8 +977,6 @@ NORET_TYPE void do_exit(long code)
disassociate_ctty(1); disassociate_ctty(1);
module_put(task_thread_info(tsk)->exec_domain->module); module_put(task_thread_info(tsk)->exec_domain->module);
if (tsk->binfmt)
module_put(tsk->binfmt->module);
proc_exit_connector(tsk); proc_exit_connector(tsk);
......
...@@ -519,6 +519,8 @@ void mmput(struct mm_struct *mm) ...@@ -519,6 +519,8 @@ void mmput(struct mm_struct *mm)
spin_unlock(&mmlist_lock); spin_unlock(&mmlist_lock);
} }
put_swap_token(mm); put_swap_token(mm);
if (mm->binfmt)
module_put(mm->binfmt->module);
mmdrop(mm); mmdrop(mm);
} }
} }
...@@ -644,9 +646,14 @@ struct mm_struct *dup_mm(struct task_struct *tsk) ...@@ -644,9 +646,14 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
mm->hiwater_rss = get_mm_rss(mm); mm->hiwater_rss = get_mm_rss(mm);
mm->hiwater_vm = mm->total_vm; mm->hiwater_vm = mm->total_vm;
if (mm->binfmt && !try_module_get(mm->binfmt->module))
goto free_pt;
return mm; return mm;
free_pt: free_pt:
/* don't put binfmt in mmput, we haven't got module yet */
mm->binfmt = NULL;
mmput(mm); mmput(mm);
fail_nomem: fail_nomem:
...@@ -1041,9 +1048,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1041,9 +1048,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
if (!try_module_get(task_thread_info(p)->exec_domain->module)) if (!try_module_get(task_thread_info(p)->exec_domain->module))
goto bad_fork_cleanup_count; goto bad_fork_cleanup_count;
if (p->binfmt && !try_module_get(p->binfmt->module))
goto bad_fork_cleanup_put_domain;
p->did_exec = 0; p->did_exec = 0;
delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
copy_flags(clone_flags, p); copy_flags(clone_flags, p);
...@@ -1331,9 +1335,6 @@ bad_fork_cleanup_cgroup: ...@@ -1331,9 +1335,6 @@ bad_fork_cleanup_cgroup:
#endif #endif
cgroup_fork_failed(p, cgroup_callbacks_done, clone_flags); cgroup_fork_failed(p, cgroup_callbacks_done, clone_flags);
delayacct_tsk_free(p); delayacct_tsk_free(p);
if (p->binfmt)
module_put(p->binfmt->module);
bad_fork_cleanup_put_domain:
module_put(task_thread_info(p)->exec_domain->module); module_put(task_thread_info(p)->exec_domain->module);
bad_fork_cleanup_count: bad_fork_cleanup_count:
atomic_dec(&p->cred->user->processes); atomic_dec(&p->cred->user->processes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment