Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757439AbbBENN0 (ORCPT ); Thu, 5 Feb 2015 08:13:26 -0500 Received: from relay.parallels.com ([195.214.232.42]:58051 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698AbbBENNY (ORCPT ); Thu, 5 Feb 2015 08:13:24 -0500 Message-ID: <1423142000.6933.3.camel@tkhai> Subject: [PATCH] de_thread: Move notify_count write under lock From: Kirill Tkhai To: CC: Oleg Nesterov , Andrew Morton , Date: Thu, 5 Feb 2015 16:13:20 +0300 Organization: Parallels Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5-2+b3 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.30.26.172] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1402 Lines: 42 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 --- 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/