From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759061AbcHaHUs (ORCPT ); Wed, 31 Aug 2016 03:20:48 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:59925 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758992AbcHaHUp (ORCPT ); Wed, 31 Aug 2016 03:20:45 -0400 Date: Wed, 31 Aug 2016 09:20:41 +0200 From: Peter Zijlstra To: Benjamin Herrenschmidt Cc: Oleg Nesterov , Balbir Singh , LKML , Nicholas Piggin Subject: Re: [RFC][PATCH] Fix a race between rwsem and the scheduler Message-ID: <20160831072041.GA10138@twins.programming.kicks-ass.net> References: <4050f2ce-1aee-d2aa-39e3-36e995b56252@gmail.com> <20160830121937.GQ10138@twins.programming.kicks-ass.net> <20160830130426.GA17795@redhat.com> <1472592301.2388.37.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472592301.2388.37.camel@kernel.crashing.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 31, 2016 at 07:25:01AM +1000, Benjamin Herrenschmidt wrote: > On Tue, 2016-08-30 at 15:04 +0200, Oleg Nesterov wrote: > > > > Confused... how this connects to UNLOCK+LOCK on rq->lock? A LOAD can > > leak into the critical section. > > > > But context switch should imply mb() we can rely on? > > Between setting of ->on_rq and returning to the task so it can > change its state back to [UN]INTERRUPTIBLE, there will be at least one > write barrier (spin unlock of the rq), spin-unlock is _not_ a write barrier, its a RELEASE barrier, and is not sufficient for this. > possibly even a full barrier > (context switch). The write barrier is enough so I didn't dig to make > sure we always context switch in the scenario we're looking at but I > think we do. There is enough, you just need to pair the RELEASE with an ACQUIRE to get a full load-store barrier.