Skip to content

Commit 80628ca

Browse files
oleg-nesterovtorvalds
authored andcommitted
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>
1 parent b57922b commit 80628ca

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎kernel/fork.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,14 +1446,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14461446
goto bad_fork_free_pid;
14471447
}
14481448

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-
14571449
if (likely(p->pid)) {
14581450
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
14591451

@@ -1470,6 +1462,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14701462
list_add_tail(&p->sibling, &p->real_parent->children);
14711463
list_add_tail_rcu(&p->tasks, &init_task.tasks);
14721464
__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);
14731472
}
14741473
attach_pid(p, PIDTYPE_PID, pid);
14751474
nr_threads++;

0 commit comments

Comments
 (0)