From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166AbcH3NFF (ORCPT ); Tue, 30 Aug 2016 09:05:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbcH3NE7 (ORCPT ); Tue, 30 Aug 2016 09:04:59 -0400 Date: Tue, 30 Aug 2016 15:04:27 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Balbir Singh , LKML , Benjamin Herrenschmidt , Nicholas Piggin Subject: Re: [RFC][PATCH] Fix a race between rwsem and the scheduler Message-ID: <20160830130426.GA17795@redhat.com> References: <4050f2ce-1aee-d2aa-39e3-36e995b56252@gmail.com> <20160830121937.GQ10138@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160830121937.GQ10138@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 Aug 2016 13:04:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/30, Peter Zijlstra wrote: > > /* > * Ensure we load p->on_rq _after_ p->state, otherwise it would > * be possible to, falsely, observe p->on_rq == 0 and get stuck > * in smp_cond_load_acquire() below. > * > * sched_ttwu_pending() try_to_wake_up() > * [S] p->on_rq = 1; [L] P->state > * UNLOCK rq->lock > * > * schedule() RMB > * LOCK rq->lock > * UNLOCK rq->lock > * > * [task p] > * [S] p->state = UNINTERRUPTIBLE [L] p->on_rq > * > * Pairs with the UNLOCK+LOCK on rq->lock from the > * last wakeup of our task and the schedule that got our task > * current. > */ 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? Oleg.