From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from merlin.infradead.org ([205.233.59.134]:59994 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbeIKQnw (ORCPT ); Tue, 11 Sep 2018 12:43:52 -0400 Date: Tue, 11 Sep 2018 13:44:29 +0200 From: Peter Zijlstra To: Sergey Senozhatsky Cc: Dmitry Safonov , linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com>, Daniel Axtens , Dmitry Vyukov , Michael Neuling , Mikulas Patocka , Nathan March , Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= , Peter Hurley , "Rong, Chen" , Tan Xiaojun , Tetsuo Handa , stable@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , "Paul E. McKenney" Subject: Re: [PATCHv3 2/6] tty/ldsem: Update waiter->task before waking up reader Message-ID: <20180911114429.GT24106@hirez.programming.kicks-ass.net> References: <20180911014821.26286-1-dima@arista.com> <20180911014821.26286-3-dima@arista.com> <20180911050449.GB4065@jagdpanzerIV> <20180911054129.GC4065@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180911054129.GC4065@jagdpanzerIV> Sender: stable-owner@vger.kernel.org List-ID: On Tue, Sep 11, 2018 at 02:41:29PM +0900, Sergey Senozhatsky wrote: > On (09/11/18 14:04), Sergey Senozhatsky wrote: > > > for (;;) { > > > set_current_state(TASK_UNINTERRUPTIBLE); > > > > I think that set_current_state() also executes memory barrier. Just > > because it accesses task state. > > > > > - if (!waiter.task) > > > + if (!READ_ONCE(waiter.task)) > > > break; > > > if (!timeout) > > > break; > > This READ_ONCE(waiter.task) looks interesting. Maybe could be moved > to a loop condition > > while (!READ_ONCE(waiter.task)) { > ... > } No, it must be after set_current_state(). See that same comment.