Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933535AbcJZPqv (ORCPT ); Wed, 26 Oct 2016 11:46:51 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:38151 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932174AbcJZPqu (ORCPT ); Wed, 26 Oct 2016 11:46:50 -0400 Date: Wed, 26 Oct 2016 17:46:47 +0200 From: Peter Zijlstra To: Dmitry Torokhov Cc: LKML , Tejun Heo , computersforpeace@gmail.com, Ingo Molnar , der.herr@hofr.at Subject: Re: complete_all and "forever" completions Message-ID: <20161026154647.GJ3157@twins.programming.kicks-ass.net> References: <20161025223054.GA22917@dtor-ws> <20161026084535.GX3102@twins.programming.kicks-ass.net> <20161026121001.GA19692@dtor-ws> <20161026154213.GD3117@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161026154213.GD3117@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 Content-Length: 936 Lines: 35 On Wed, Oct 26, 2016 at 05:42:13PM +0200, Peter Zijlstra wrote: > Does something like so work? try_wait_for_completion() would need a similar change. > --- > kernel/sched/completion.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c > index 8d0f35debf35..5deab9c789df 100644 > --- a/kernel/sched/completion.c > +++ b/kernel/sched/completion.c > @@ -51,7 +51,7 @@ void complete_all(struct completion *x) > unsigned long flags; > > spin_lock_irqsave(&x->wait.lock, flags); > - x->done += UINT_MAX/2; > + x->done = UINT_MAX/2; > __wake_up_locked(&x->wait, TASK_NORMAL, 0); > spin_unlock_irqrestore(&x->wait.lock, flags); > } > @@ -79,7 +79,10 @@ do_wait_for_common(struct completion *x, > if (!x->done) > return timeout; > } > - x->done--; > + > + if (x->done != UINT_MAX/2) > + x->done--; > + > return timeout ?: 1; > } >