Re: [PATCH] Repost sched-rt: Reduce rq lock contention by eliminating locking of non-feasible target

From: Tim Chen
Date: Fri Jan 16 2015 - 12:46:23 EST


On Thu, 2015-01-15 at 20:58 -0500, Steven Rostedt wrote:

>
> Please add a comment here that says something like:
>
> /*
> * Don't bother moving it if the destination CPU is
> * not running a lower priority task.
> */
>
Okay. Updated in patch below.

> > - if (target != -1)
> > + if (target != -1 &&
> > + p->prio < cpu_rq(target)->rt.highest_prio.curr)
> > cpu = target;
> > }
> > rcu_read_unlock();
> > @@ -1613,6 +1614,12 @@ static struct rq *find_lock_lowest_rq(struct
> > task_struct *task, struct rq *rq) break;
> >
> > lowest_rq = cpu_rq(cpu);
> > +
> > + if (lowest_rq->rt.highest_prio.curr <= task->prio) {
> > + /* target rq has tasks of equal or higher priority,
> > try again */
> > + lowest_rq = NULL;
> > + continue;
>
> This should just break out and not try again. The reason for the other
> try again is because of the double_lock which can release the locks
> which can cause a process waiting for the lock to sneak in and
> change the priorities. But this case, a try again is highly unlikely to
> do anything differently (no locks are released) and just waste cycles.

Agree. Updated in updated patch below.

Thanks.

Tim

---->8------