public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] de_thread: Move notify_count write under lock
@ 2015-02-05 13:13 Kirill Tkhai
  2015-02-05 13:38 ` Oleg Nesterov
  2015-02-23 20:18 ` Oleg Nesterov
  0 siblings, 2 replies; 9+ messages in thread
From: Kirill Tkhai @ 2015-02-05 13:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Oleg Nesterov, Andrew Morton, tkhai


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);




^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-23 20:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05 13:13 [PATCH] de_thread: Move notify_count write under lock Kirill Tkhai
2015-02-05 13:38 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox