Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752143AbdIAOeO (ORCPT ); Fri, 1 Sep 2017 10:34:14 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50020 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751991AbdIAOeN (ORCPT ); Fri, 1 Sep 2017 10:34:13 -0400 Date: Fri, 1 Sep 2017 07:34:01 -0700 From: "Paul E. McKenney" To: Nicholas Piggin Cc: Andrea Parri , Ingo Molnar , Peter Zijlstra , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: [PATCH] swait: add missing barrier to swake_up Reply-To: paulmck@linux.vnet.ibm.com References: <20170901061450.1450-1-npiggin@gmail.com> <20170901092322.GA4192@andrea> <20170901195529.6edca064@roar.ozlabs.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170901195529.6edca064@roar.ozlabs.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17090114-0048-0000-0000-000001DD09B9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007647; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00910721; UDB=6.00456882; IPR=6.00691001; BA=6.00005563; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016962; XFM=3.00000015; UTC=2017-09-01 14:34:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090114-0049-0000-0000-0000426B768B Message-Id: <20170901143401.GR4431@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-01_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709010206 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1573 Lines: 37 On Fri, Sep 01, 2017 at 07:55:29PM +1000, Nicholas Piggin wrote: > On Fri, 1 Sep 2017 11:23:22 +0200 > Andrea Parri wrote: > > > On Fri, Sep 01, 2017 at 04:14:50PM +1000, Nicholas Piggin wrote: > > > swake_up and swake_up_all test the swaitqueue outside the lock, > > > but they are missing the barrier that would ensure visibility > > > of a previous store that sets the wakeup condition with the > > > load that tests the swaitqueue. This could lead to a lost wakeup > > > if there is memory reordering. Fix this as prescribed by the > > > waitqueue_active comments. > > > > > > Signed-off-by: Nicholas Piggin > > > -- > > > I noticed this when chasing down that rcu hang bug (which > > > turned out to not be anything of the sort). I might be missing > > > something here and it's safe somehow, but if so then it should > > > have a comment where it diverges from normal waitqueues. > > > > > > It looks like there's a few callers which are also testing > > > swait_active before swake_up without a barrier which look wrong, > > > so I must be missing something but I'm not sure what. > > > > Hi Nicholas. I noticed > > > > 35a2897c2a306cca344ca5c0b43416707018f434 > > ("sched/wait: Remove the lockless swait_active() check in swake_up*()") > > > > in tip:locking/core. > > Oh thanks, I missed that. Should be in 4.14/stable IMO. This might well have been helpful to me -- I had forgotten about that fix and am testing without it -- and suffering what look to be lost timeouts/wakeups. :-/ Thanx, Paul