From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755559Ab3I3SVB (ORCPT ); Mon, 30 Sep 2013 14:21:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5346 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754625Ab3I3SVA (ORCPT ); Mon, 30 Sep 2013 14:21:00 -0400 Date: Mon, 30 Sep 2013 20:13:58 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Ingo Molnar , Paul McKenney , Linus Torvalds , Thomas Gleixner , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/6] sched, wait: Collapse __wait_event macros -v4 Message-ID: <20130930181358.GA29544@redhat.com> References: <20130930152242.207382649@infradead.org> <20130930174054.GA28129@redhat.com> <20130930180939.GN15690@laptop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130930180939.GN15690@laptop.programming.kicks-ass.net> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/30, Peter Zijlstra wrote: > > On Mon, Sep 30, 2013 at 07:40:54PM +0200, Oleg Nesterov wrote: > > Once again, of course I do not blame this series, but > > wait_event_timeout(wq, true, 0) still returns 0. > > So we have: > > [...snip...] > So wait_event_timeout(wq, true, 0) turns into: Not really, because of fast-path check, #define wait_event_timeout(wq, condition, timeout) \ ({ \ long __ret = timeout; \ if (!(condition)) \ __ret = __wait_event_timeout(wq, condition, timeout); \ __ret; \ }) we do not even call __wait_event_timeout() if "condition" is already true at the start. > > ___wait_event(wq, ___wait_cond_timeout(condition), \ > > TASK_INTERRUPTIBLE, 0, ret, \ > > spin_unlock_irq(&lock); \ > > - __ret = schedule_timeout(__ret); \ > > + ___wait_schedule_timeout(__ret); \ > > spin_lock_irq(&lock)); > > You can't do that; you'll break/return without the lock held. Yes, see another email, already noticed this. And let me repeat just in case, I think this series is fine, just wait.h needs another minor/orthogonal fix. Oleg.