Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80628ca0 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

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: default avatarOleg 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b57922b6
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -1446,14 +1446,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
		goto bad_fork_free_pid;
		goto bad_fork_free_pid;
	}
	}


	if (clone_flags & CLONE_THREAD) {
		current->signal->nr_threads++;
		atomic_inc(&current->signal->live);
		atomic_inc(&current->signal->sigcnt);
		p->group_leader = current->group_leader;
		list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group);
	}

	if (likely(p->pid)) {
	if (likely(p->pid)) {
		ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
		ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);


@@ -1470,6 +1462,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
			list_add_tail(&p->sibling, &p->real_parent->children);
			list_add_tail(&p->sibling, &p->real_parent->children);
			list_add_tail_rcu(&p->tasks, &init_task.tasks);
			list_add_tail_rcu(&p->tasks, &init_task.tasks);
			__this_cpu_inc(process_counts);
			__this_cpu_inc(process_counts);
		} else {
			current->signal->nr_threads++;
			atomic_inc(&current->signal->live);
			atomic_inc(&current->signal->sigcnt);
			p->group_leader = current->group_leader;
			list_add_tail_rcu(&p->thread_group,
					  &p->group_leader->thread_group);
		}
		}
		attach_pid(p, PIDTYPE_PID, pid);
		attach_pid(p, PIDTYPE_PID, pid);
		nr_threads++;
		nr_threads++;