Skip to contentSkip to conversation

sched/deadline: Compare against the donor in prio_changed_dl()

PATCH New Zhan Xusheng 1 participant 1 message Oct 5 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched/deadline: Compare against the donor in prio_changed_dl()

prio_changed_dl() dispatches on task_current_donor(), so its else branch asks whether p should preempt the current scheduling context. Under proxy execution that is rq->donor; rq->curr is the execution context and may be a mutex owner running on the donor's parameters. dl_task() tests dl_prio(p->prio), so dl_task(rq->curr) says nothing about what the runqueue is currently scheduling.

commit af0c8b2bf67b ("sched: Split scheduler and execution contexts") converted the identical else branch of prio_changed_rt() to rq->donor. Its hunk for deadline.c enters prio_changed_dl() and converts task_current() to task_current_donor(), but leaves the comparison below it on rq->curr.

Fixes af0c8b2bf67b ("sched: Split scheduler and execution contexts")

---
Changes since v1:

- Dropped the claim that the donor test implies the curr test. It does
not: with a non-DL donor and a DL rq->curr the donor test is true while the curr test can be false, so the current code can also skip a reschedule, not only add one.
- Dropped the suggestion to convert dl_server_timer() and dl_server_start(). Yuri Andriaccio's "sched/deadline: Do not access dl_se->rq directly" (RFC v6 03/25) rewrites both of those lines, turning dl_se->rq into a local rq while keeping ->curr, so a donor conversion there is better done on top of that series than against it. prio_changed_dl() is not touched by it.

Built with CONFIG_SCHED_PROXY_EXEC=y and =n. With =n the two rq members are an anonymous union and kernel/sched/build_policy.o is byte-identical to the unpatched tree.

v1: https://patch.msgid.link/[email protected]

 kernel/sched/deadline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +2 -2
index 0663c00c41c0..f27aa930420f 100644
@@ -3631,8 +3631,8 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p, u64 old_deadli
 		 *
 		 * Otherwise, if p was given an earlier deadline, reschedule.
 		 */
-		if (!dl_task(rq->curr) ||
-		    dl_time_before(p->dl.deadline, rq->curr->dl.deadline))
+		if (!dl_task(rq->donor) ||
+		    dl_time_before(p->dl.deadline, rq->donor->dl.deadline))
 			resched_curr(rq);
 	}
 }

base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a

Signature · 1 line
2.43.0