From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758264AbcH3VZp (ORCPT ); Tue, 30 Aug 2016 17:25:45 -0400 Received: from gate.crashing.org ([63.228.1.57]:41922 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753220AbcH3VZo (ORCPT ); Tue, 30 Aug 2016 17:25:44 -0400 Message-ID: <1472592301.2388.37.camel@kernel.crashing.org> Subject: Re: [RFC][PATCH] Fix a race between rwsem and the scheduler From: Benjamin Herrenschmidt To: Oleg Nesterov , Peter Zijlstra Cc: Balbir Singh , LKML , Nicholas Piggin Date: Wed, 31 Aug 2016 07:25:01 +1000 In-Reply-To: <20160830130426.GA17795@redhat.com> References: <4050f2ce-1aee-d2aa-39e3-36e995b56252@gmail.com> <20160830121937.GQ10138@twins.programming.kicks-ass.net> <20160830130426.GA17795@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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), 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. Cheers, Ben.