Re: [PATCH] sched: Check nr_running before calling pick_next_task in schedule().

Rakib Mullick
2011-07-02T04:37:51Z

Hi Paul,

On Sat, Jul 2, 2011 at 8:23 AM, Paul Turner <pjt@google.com> wrote:
> Hi Rakib,
>
> This doesn't strike me as a very good trade.
>
I'm not sure why. What am I missing here?

> It adds a branch to the case where we actually have work to save branches in
> the case when we're idle anyway?

Yes, right. We're adding a branch here. Is it a misuse of branch? As I
mentioned, idle_balance can fail (I think thats an unlikely case, that
why I've added a branch). In that case, we don't need to call
pick_next_task. Note, in pick_next_task there is a check for
'likely(rq->nr_running == rq->cfs.nr_running)' - by using this patch
that case will be more likely (which itself calls
fair_sched_class.pick_next_task directly - which is an optimization).
If calling fair_sched_class.pick_next_task in case of all tasks are
cfs task is being treat as an optimization then why, when we're idle
calling idle_sched_class.pick_next_task, won't be an optimization?

Thanks,
Rakib

>
> - Paul
>