From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753679AbcIBMHV (ORCPT ); Fri, 2 Sep 2016 08:07:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36286 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751982AbcIBMHT (ORCPT ); Fri, 2 Sep 2016 08:07:19 -0400 Date: Fri, 2 Sep 2016 14:06:43 +0200 From: Oleg Nesterov To: Peter Zijlstra 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: <20160902120642.GC26495@redhat.com> References: <20160826124453.GA28894@redhat.com> <20160826124552.GB28904@redhat.com> <20160901190141.GJ10138@twins.programming.kicks-ass.net> <20160901221743.GJ10168@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160901221743.GJ10168@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.31]); Fri, 02 Sep 2016 12:07:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/02, Peter Zijlstra wrote: > > 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. And __wait_event_interruptible_locked() too. BTW it is buggy anyway, it needs the - __add_wait_queue_tail(&(wq), &__wait); + if (exclusive) + __add_wait_queue_tail(&(wq), &__wait); + else + __add_wait_queue((&(wq), &__wait); and in fact it should use __add_wait_queue_exclusive() so that we can remove another "if (exclusive)" but this is off-topic. Yes, I considered this option, but to me the addtional finish_wait() looks simpler. And, if you agree with this change I will try to change __wait_event() as well and kill abort_exclusive_wait(). And in this case we certainly do not want to check the "condition" with q->lock held, because this would mean that "condition" won't be able to take this lock. Oleg.