Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754383AbcCWKny (ORCPT ); Wed, 23 Mar 2016 06:43:54 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35980 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbcCWKnr (ORCPT ); Wed, 23 Mar 2016 06:43:47 -0400 Date: Wed, 23 Mar 2016 11:43:44 +0100 From: Michal Hocko To: Peter Zijlstra Cc: Johannes Weiner , Andrew Morton , linux-mm@kvack.org, LKML , Tetsuo Handa , David Rientjes , Ingo Molnar , Thomas Gleixner Subject: Re: [PATCH 1/9] sched: add schedule_timeout_idle() Message-ID: <20160323104344.GC7059@dhcp22.suse.cz> References: <1458644426-22973-1-git-send-email-mhocko@kernel.org> <1458644426-22973-2-git-send-email-mhocko@kernel.org> <20160322122345.GN6344@twins.programming.kicks-ass.net> <20160322123314.GD10381@dhcp22.suse.cz> <20160322125113.GO6344@twins.programming.kicks-ass.net> <20160322130822.GF10381@dhcp22.suse.cz> <20160322132249.GP6344@twins.programming.kicks-ass.net> <20160322175626.GA13302@cmpxchg.org> <20160322212352.GF6356@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160322212352.GF6356@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 885 Lines: 34 On Tue 22-03-16 22:23:52, Peter Zijlstra wrote: [...] > Probably. However, with such semantics the schedule*() name is wrong > too, you cannot use these functions to build actual wait loops etc. > > So maybe: > > static inline long sleep_in_state(long timeout, long state) > { > __set_current_state(state); > return schedule_timeout(timeout); > } > > might be an even better name; but at that point we look very like the > msleep*() class of function, so maybe we should do: > > long sleep_in_state(long state, long timeout) > { > while (timeout && !signal_pending_state(state, current)) { > __set_current_state(state); > timeout = schedule_timeout(timeout); > } > return timeout; > } > > Hmm ? I am not sure how many callers do care about premature wake-ups (e.g I could find a use for it) but this indeed has a better and cleaner semantic. -- Michal Hocko SUSE Labs