Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752333AbcCVVYH (ORCPT ); Tue, 22 Mar 2016 17:24:07 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:47008 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751510AbcCVVYG (ORCPT ); Tue, 22 Mar 2016 17:24:06 -0400 Date: Tue, 22 Mar 2016 22:23:52 +0100 From: Peter Zijlstra To: Johannes Weiner Cc: Michal Hocko , 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: <20160322212352.GF6356@twins.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160322175626.GA13302@cmpxchg.org> 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 Content-Length: 1499 Lines: 46 On Tue, Mar 22, 2016 at 01:56:26PM -0400, Johannes Weiner wrote: > On Tue, Mar 22, 2016 at 02:22:49PM +0100, Peter Zijlstra wrote: > > On Tue, Mar 22, 2016 at 02:08:23PM +0100, Michal Hocko wrote: > > > On Tue 22-03-16 13:51:13, Peter Zijlstra wrote: > > > If that sounds like a more appropriate plan I won't object. I can simply > > > change my patch to do __set_current_state and schedule_timeout. > > > > I dunno, I just think these wrappers are silly. > > Adding out-of-line, exported wrappers for every single task state is > kind of silly. But it's still a common operation to wait in a certain > state, so having a single function for that makes sense. Kind of like > spin_lock_irqsave and friends. > > Maybe this would be better?: > > static inline long schedule_timeout_state(long timeout, long state) > { > __set_current_state(state); > return schedule_timeout(timeout); > } 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 ?