Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbbEZTrC (ORCPT ); Tue, 26 May 2015 15:47:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42645 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbbEZTq6 (ORCPT ); Tue, 26 May 2015 15:46:58 -0400 Date: Tue, 26 May 2015 21:46:13 +0200 From: Oleg Nesterov To: Kirill Tkhai Cc: linux-kernel@vger.kernel.org, Andrew Morton , Ingo Molnar , Peter Zijlstra , Michal Hocko , Rik van Riel , Ionut Alexa , Peter Hurley , Kirill Tkhai Subject: Re: [PATCH RFC 09/13] exit: Use for_each_thread() in do_wait() Message-ID: <20150526194613.GC6978@redhat.com> References: <20150525162722.5171.15901.stgit@pro> <1432575941.6866.42.camel@odin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432575941.6866.42.camel@odin.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1099 Lines: 38 On 05/25, Kirill Tkhai wrote: > > Refactoring, no functionality change. Hmm. unless I missed something this change is wrong. > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -1538,8 +1538,7 @@ static long do_wait(struct wait_opts *wo) > > set_current_state(TASK_INTERRUPTIBLE); > read_lock(&tasklist_lock); > - tsk = current; > - do { > + for_each_thread(current, tsk) { > retval = do_wait_thread(wo, tsk); > if (retval) > goto end; > @@ -1550,7 +1549,7 @@ static long do_wait(struct wait_opts *wo) > > if (wo->wo_flags & __WNOTHREAD) > break; > - } while_each_thread(current, tsk); > + } Please note the __WNOTHREAD check. This is the rare case when we actually want while_each_thread() (although it should die anyway). for_each_thread() always starts from ->group_leader, but we need to start from "current" first. Oleg. -- 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/