From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752690AbcIAWRy (ORCPT ); Thu, 1 Sep 2016 18:17:54 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45537 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbcIAWRx (ORCPT ); Thu, 1 Sep 2016 18:17:53 -0400 Date: Fri, 2 Sep 2016 00:17:43 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: Ingo Molnar , Al Viro , Bart Van Assche , Johannes Weiner , Linus Torvalds , Neil Brown , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Message-ID: <20160901221743.GJ10168@twins.programming.kicks-ass.net> References: <20160826124453.GA28894@redhat.com> <20160826124552.GB28904@redhat.com> <20160901190141.GJ10138@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160901190141.GJ10138@twins.programming.kicks-ass.net> 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 Thu, Sep 01, 2016 at 09:01:41PM +0200, Peter Zijlstra wrote: > On Fri, Aug 26, 2016 at 02:45:52PM +0200, Oleg Nesterov wrote: > > > We do not need anything tricky to avoid the race, > > The race being: > > CPU0 CPU1 CPU2 > > __wait_on_bit_lock() > bit_wait_io() > io_schedule() > > clear_bit_unlock() > __wake_up_common(.nr_exclusive=1) > list_for_each_entry() > if (curr->func() && --nr_exclusive) > break > > signal() > > if (signal_pending_state()) == TRUE > return -EINTR > > And no progress because CPU1 exits without acquiring the lock and CPU0 > thinks its done because it woke someone. FWIW, the way the mutex code avoids this issue is by doing the signal_pending test while holding the q->lock, that way its exclusive with wakeup.