From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbbJLL6q (ORCPT ); Mon, 12 Oct 2015 07:58:46 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:51774 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751725AbbJLL6d (ORCPT ); Mon, 12 Oct 2015 07:58:33 -0400 Date: Mon, 12 Oct 2015 13:58:29 +0200 From: Peter Zijlstra To: Daniel Wagner Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 3/8] sched/completion: convert completions to use simple wait queues Message-ID: <20151012115829.GN3816@twins.programming.kicks-ass.net> References: <1441800334-16609-1-git-send-email-daniel.wagner@bmw-carit.de> <1441800334-16609-4-git-send-email-daniel.wagner@bmw-carit.de> <20150909142608.GP12596@twins.programming.kicks-ass.net> <561B7A9A.3020904@bmw-carit.de> <561B855A.2060403@bmw-carit.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <561B855A.2060403@bmw-carit.de> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2015 at 12:03:06PM +0200, Daniel Wagner wrote: > On 10/12/2015 11:17 AM, Daniel Wagner wrote: > > On 09/09/2015 04:26 PM, Peter Zijlstra wrote: > >> On Wed, Sep 09, 2015 at 02:05:29PM +0200, Daniel Wagner wrote: > >>> @@ -50,10 +50,10 @@ void complete_all(struct completion *x) > >>> { > >>> unsigned long flags; > >>> > >>> - spin_lock_irqsave(&x->wait.lock, flags); > >>> + raw_spin_lock_irqsave(&x->wait.lock, flags); > >>> x->done += UINT_MAX/2; > >>> - __wake_up_locked(&x->wait, TASK_NORMAL, 0); > >>> - spin_unlock_irqrestore(&x->wait.lock, flags); > >>> + swake_up_locked(&x->wait); > >>> + raw_spin_unlock_irqrestore(&x->wait.lock, flags); > >>> } > >>> EXPORT_SYMBOL(complete_all); > >> > >> I don't think that's correct; __wake_up_locked(.nr=0) would wake all > >> waiters, where swake_up_locked() will only wake one. > > > > I read that x->done should be protected via wait.lock during the whole > > operation. swake_up_all() will release and reacquire the lock while > > processing the all waiters. So we need to get > > > > Could we play a trick like setting the highest bit in done for > > indicating the complete_all() operation. The UINT_MAX/2 update looks > > like do this by setting a value which has the biggest offset from 0 (but > > why adding instead of just going for assigning...). > > > I had something like this here in mind: I'm not exactly sure what problem you're trying to solve here.. The fact that we cannot call swake_all() while holding &x->wait.lock, or the fact that complete_all() is typically called from a context which cannot do swake_all() either? Note: Documentation/scheduler/completion.txt:complete() and complete_all() can be called in hard-irq/atomic context safely. Which is very much _NOT_ true of swake_all().