Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1363025

Re: [PATCH 1/9] sched: add schedule_timeout_idle()

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/9] sched: add schedule_timeout_idle()
Date 2016-03-22 22:30 +0100
Message-ID <rfC2d-1V8-5@gated-at.bofh.it> (permalink)
References (3 earlier) <rftLl-4o3-31@gated-at.bofh.it> <rfu4G-4uD-9@gated-at.bofh.it> <rfuem-4Pn-17@gated-at.bofh.it> <rfuxH-4WW-1@gated-at.bofh.it> <rfyL0-88A-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 ?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/9] sched: add schedule_timeout_idle() Michal Hocko <mhocko@kernel.org> - 2016-03-22 12:10 +0100
  Re: [PATCH 1/9] sched: add schedule_timeout_idle() Peter Zijlstra <peterz@infradead.org> - 2016-03-22 13:30 +0100
    Re: [PATCH 1/9] sched: add schedule_timeout_idle() Michal Hocko <mhocko@kernel.org> - 2016-03-22 13:40 +0100
      Re: [PATCH 1/9] sched: add schedule_timeout_idle() Peter Zijlstra <peterz@infradead.org> - 2016-03-22 14:00 +0100
        Re: [PATCH 1/9] sched: add schedule_timeout_idle() Michal Hocko <mhocko@kernel.org> - 2016-03-22 14:10 +0100
          Re: [PATCH 1/9] sched: add schedule_timeout_idle() Peter Zijlstra <peterz@infradead.org> - 2016-03-22 14:30 +0100
            Re: [PATCH 1/9] sched: add schedule_timeout_idle() Johannes Weiner <hannes@cmpxchg.org> - 2016-03-22 19:00 +0100
              Re: [PATCH 1/9] sched: add schedule_timeout_idle() Peter Zijlstra <peterz@infradead.org> - 2016-03-22 22:30 +0100
                Re: [PATCH 1/9] sched: add schedule_timeout_idle() Michal Hocko <mhocko@kernel.org> - 2016-03-23 11:50 +0100
    Re: [PATCH 1/9] sched: add schedule_timeout_idle() Andrew Morton <akpm@linux-foundation.org> - 2016-03-23 00:10 +0100

csiph-web