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

Michal Hocko
2016-03-23T10:43:54Z

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