From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Michal Hocko <mhocko@suse.cz>,
Pavel Emelyanov <xemul@parallels.com>,
Sergey Dyasly <dserrg@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] copy_process: unify CLONE_THREAD-or-thread_group_leader code
Date: Sun, 9 Jun 2013 19:00:26 +0200 [thread overview]
Message-ID: <20130609170026.GA5236@redhat.com> (raw)
In-Reply-To: <20130609170007.GA5215@redhat.com>
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>
---
kernel/fork.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 987b28a..7bc4146 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1446,14 +1446,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
goto bad_fork_free_pid;
}
- if (clone_flags & CLONE_THREAD) {
- current->signal->nr_threads++;
- atomic_inc(¤t->signal->live);
- atomic_inc(¤t->signal->sigcnt);
- p->group_leader = current->group_leader;
- list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group);
- }
-
if (likely(p->pid)) {
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_rcu(&p->tasks, &init_task.tasks);
__this_cpu_inc(process_counts);
+ } else {
+ current->signal->nr_threads++;
+ atomic_inc(¤t->signal->live);
+ atomic_inc(¤t->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);
nr_threads++;
--
1.5.5.1
next prev parent reply other threads:[~2013-06-09 17:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 17:00 [PATCH v2 0/4] copy_process/attach_pid minor fix + cleanups Oleg Nesterov
2013-06-09 17:00 ` [PATCH 1/4] de_thread: use change_pid() rather than detach_pid/attach_pid Oleg Nesterov
2013-06-10 4:07 ` Eric W. Biederman
2013-06-09 17:00 ` Oleg Nesterov [this message]
2013-06-09 17:00 ` [PATCH 3/4] copy_process: don't add the uninitialized child to thread/task/pid lists Oleg Nesterov
2013-06-09 17:00 ` [PATCH 4/4] copy_process: consolidate the lockless CLONE_THREAD checks Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130609170026.GA5236@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dserrg@gmail.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox