From: Kirill Tkhai <ktkhai@parallels.com>
To: <linux-kernel@vger.kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>, <tkhai@yandex.ru>
Subject: [PATCH] de_thread: Move notify_count write under lock
Date: Thu, 5 Feb 2015 16:13:20 +0300 [thread overview]
Message-ID: <1423142000.6933.3.camel@tkhai> (raw)
The write operation may be reordered with the setting of group_exit_task.
If so, this fires in exit_notify().
Looks like, it's not good to add smp barriers for this case, especially
in exit_notify(), so let's put the notify_count write under write lock.
Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
---
fs/exec.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index ad8798e..42782d5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -920,10 +920,16 @@ static int de_thread(struct task_struct *tsk)
if (!thread_group_leader(tsk)) {
struct task_struct *leader = tsk->group_leader;
- sig->notify_count = -1; /* for exit_notify() */
for (;;) {
threadgroup_change_begin(tsk);
write_lock_irq(&tasklist_lock);
+ /*
+ * We could set it once outside the for() cycle, but
+ * this requires to use SMP barriers there and in
+ * exit_notify(), because the write operation may
+ * be reordered with the setting of group_exit_task.
+ */
+ sig->notify_count = -1; /* for exit_notify() */
if (likely(leader->exit_state))
break;
__set_current_state(TASK_KILLABLE);
next reply other threads:[~2015-02-05 13:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 13:13 Kirill Tkhai [this message]
2015-02-05 13:38 ` [PATCH] de_thread: Move notify_count write under lock Oleg Nesterov
2015-02-05 14:15 ` Kirill Tkhai
2015-02-05 14:27 ` Kirill Tkhai
2015-02-05 17:09 ` Oleg Nesterov
2015-02-05 16:11 ` Kirill Tkhai
2015-02-05 16:49 ` Kirill Tkhai
2015-02-05 17:18 ` Oleg Nesterov
2015-02-23 20:18 ` 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=1423142000.6933.3.camel@tkhai \
--to=ktkhai@parallels.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tkhai@yandex.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.