Messages in this thread Patch in this message | | | Date | Thu, 25 Feb 2016 15:01:49 +0100 | From | Peter Zijlstra <> | Subject | Re: Question about prio_changed_dl() |
| |
On Fri, Feb 19, 2016 at 01:43:45PM +0100, luca abeni wrote: > Hi, > > when playing with the __dl_{add,sub}_ac() stuff recently posted by > Juri, I found something that looks strange in prio_changed_dl(): > > static void prio_changed_dl(struct rq *rq, struct task_struct *p, > int oldprio) > { > if (task_on_rq_queued(p) || rq->curr == p) { > [...] > } else > switched_to_dl(rq, p); > } > but switched_to_dl() does: > static void switched_to_dl(struct rq *rq, struct task_struct *p) > { > if (task_on_rq_queued(p) && rq->curr != p) { > [...] > } > } > > so, prio_changed_dl() invokes switched_to_dl() if task_on_rq_queued() > is false, but in this case switched_to_dl() does nothing... Am I > missing something, or the > } else > switched_to_dl(rq, p); > is useless?
Agreed, see below.
> (BTW, it seems to me that switched_to_dl() is never invoked, for some > reason...)
Hmm, it should be invoked if you do sched_setattr() to get SCHED_DEADLINE.
--- Subject: sched/deadline: Remove superfluous call to switched_to_dl()
if (A || B) {
} else if (A && !B) {
}
If A we'll take the first branch, if !A we will not satisfy the second. Therefore the second branch will never be taken.
Cc: Juri Lelli <juri.lelli@arm.com> Reported-by: luca abeni <luca.abeni@unitn.it> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- kernel/sched/deadline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 57b939c81bce..c161c53d9424 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1768,8 +1768,7 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p, */ resched_curr(rq); #endif /* CONFIG_SMP */ - } else - switched_to_dl(rq, p); + } } const struct sched_class dl_sched_class = {
| |