aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-03 18:08:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:08:03 -0400
commit80628ca06c5d42929de6bc22c0a41589a834d151 (patch)
treea76f3264bac4b21554221ac54bddc69c759aed9b /kernel/fork.c
parentb57922b6c76c3ee401bb32fd3f298409dd6e6a53 (diff)
kernel/fork.c:copy_process(): unify CLONE_THREAD-or-thread_group_leader code
Cleanup and preparation for the next changes. Move the "if (clone_flags & CLONE_THREAD)" code down under "if (likely(p->pid))" and turn it into into the "else" branch. This makes the process/thread initialization more symmetrical and removes one check. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Sergey Dyasly <dserrg@gmail.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.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 09dbda38a54b..417cb864e20c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1446,14 +1446,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1446 goto bad_fork_free_pid; 1446 goto bad_fork_free_pid;
1447 } 1447 }
1448 1448
1449 if (clone_flags & CLONE_THREAD) {
1450 current->signal->nr_threads++;
1451 atomic_inc(&current->signal->live);
1452 atomic_inc(&current->signal->sigcnt);
1453 p->group_leader = current->group_leader;
1454 list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group);
1455 }
1456
1457 if (likely(p->pid)) { 1449 if (likely(p->pid)) {
1458 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace); 1450 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
1459 1451
@@ -1470,6 +1462,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1470 list_add_tail(&p->sibling, &p->real_parent->children); 1462 list_add_tail(&p->sibling, &p->real_parent->children);
1471 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1463 list_add_tail_rcu(&p->tasks, &init_task.tasks);
1472 __this_cpu_inc(process_counts); 1464 __this_cpu_inc(process_counts);
1465 } else {
1466 current->signal->nr_threads++;
1467 atomic_inc(&current->signal->live);
1468 atomic_inc(&current->signal->sigcnt);
1469 p->group_leader = current->group_leader;
1470 list_add_tail_rcu(&p->thread_group,
1471 &p->group_leader->thread_group);
1473 } 1472 }
1474 attach_pid(p, PIDTYPE_PID, pid); 1473 attach_pid(p, PIDTYPE_PID, pid);
1475 nr_threads++; 1474 nr_threads++;