Re: [RFC V2 1/2] sched: Start tracking SCHED_IDLE tasks count in cfs_rq

From: Peter Zijlstra
Date: Fri May 10 2019 - 02:57:26 EST


On Thu, Apr 25, 2019 at 03:07:39PM +0530, Viresh Kumar wrote:
> @@ -5166,6 +5170,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
> {
> struct cfs_rq *cfs_rq;
> struct sched_entity *se = &p->se;
> + int idle_h_nr_running = unlikely(task_has_idle_policy(p)) ? 1 : 0;
>
> /*
> * The code below (indirectly) updates schedutil which looks at

> @@ -5266,6 +5273,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
> struct cfs_rq *cfs_rq;
> struct sched_entity *se = &p->se;
> int task_sleep = flags & DEQUEUE_SLEEP;
> + int idle_h_nr_running = unlikely(task_has_idle_policy(p)) ? 1 : 0;
>
> for_each_sched_entity(se) {
> cfs_rq = cfs_rq_of(se);

That's a completely pointless branch there (and I suspect the compiler
will see that too), just write:

int idle_h_nr_running = task_has_idle_policy(p);