Skip to content

Commit 96a6988

Browse files
johnstultz-workPeter Zijlstra
authored andcommitted
sched: deadline: Add some helper variables to cleanup deadline logic
As part of an improvement to handling pushable deadline tasks, Peter suggested this cleanup[1], to use helper values for dl_entity and dl_rq in the enqueue_task_dl() and put_prev_task_dl() functions. There should be no functional change from this patch. To make sure this cleanup change doesn't obscure later logic changes, I've split it into its own patch. [1]: https://lore.kernel.org/lkml/20260304095123.GP606826@noisy.programming.kicks-ass.net/ Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: John Stultz <jstultz@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260512025635.2840817-3-jstultz@google.com
1 parent 7a3a6bf commit 96a6988

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

kernel/sched/deadline.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,10 @@ static void dequeue_dl_entity(struct sched_dl_entity *dl_se, int flags)
24842484

24852485
static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
24862486
{
2487-
if (is_dl_boosted(&p->dl)) {
2487+
struct sched_dl_entity *dl_se = &p->dl;
2488+
struct dl_rq *dl_rq = &rq->dl;
2489+
2490+
if (is_dl_boosted(dl_se)) {
24882491
/*
24892492
* Because of delays in the detection of the overrun of a
24902493
* thread's runtime, it might be the case that a thread
@@ -2497,14 +2500,14 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
24972500
*
24982501
* In this case, the boost overrides the throttle.
24992502
*/
2500-
if (p->dl.dl_throttled) {
2503+
if (dl_se->dl_throttled) {
25012504
/*
25022505
* The replenish timer needs to be canceled. No
25032506
* problem if it fires concurrently: boosted threads
25042507
* are ignored in dl_task_timer().
25052508
*/
2506-
cancel_replenish_timer(&p->dl);
2507-
p->dl.dl_throttled = 0;
2509+
cancel_replenish_timer(dl_se);
2510+
dl_se->dl_throttled = 0;
25082511
}
25092512
} else if (!dl_prio(p->normal_prio)) {
25102513
/*
@@ -2516,7 +2519,7 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
25162519
* being boosted again with no means to replenish the runtime and clear
25172520
* the throttle.
25182521
*/
2519-
p->dl.dl_throttled = 0;
2522+
dl_se->dl_throttled = 0;
25202523
if (!(flags & ENQUEUE_REPLENISH))
25212524
printk_deferred_once("sched: DL de-boosted task PID %d: REPLENISH flag missing\n",
25222525
task_pid_nr(p));
@@ -2525,20 +2528,20 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
25252528
}
25262529

25272530
check_schedstat_required();
2528-
update_stats_wait_start_dl(dl_rq_of_se(&p->dl), &p->dl);
2531+
update_stats_wait_start_dl(dl_rq, dl_se);
25292532

25302533
if (p->on_rq == TASK_ON_RQ_MIGRATING)
25312534
flags |= ENQUEUE_MIGRATING;
25322535

2533-
enqueue_dl_entity(&p->dl, flags);
2536+
enqueue_dl_entity(dl_se, flags);
25342537

2535-
if (dl_server(&p->dl))
2538+
if (dl_server(dl_se))
25362539
return;
25372540

25382541
if (task_is_blocked(p))
25392542
return;
25402543

2541-
if (!task_current(rq, p) && !p->dl.dl_throttled && p->nr_cpus_allowed > 1)
2544+
if (!task_current(rq, p) && !dl_se->dl_throttled && p->nr_cpus_allowed > 1)
25422545
enqueue_pushable_dl_task(rq, p);
25432546
}
25442547

@@ -2835,7 +2838,7 @@ static void put_prev_task_dl(struct rq *rq, struct task_struct *p, struct task_s
28352838
struct sched_dl_entity *dl_se = &p->dl;
28362839
struct dl_rq *dl_rq = &rq->dl;
28372840

2838-
if (on_dl_rq(&p->dl))
2841+
if (on_dl_rq(dl_se))
28392842
update_stats_wait_start_dl(dl_rq, dl_se);
28402843

28412844
update_curr_dl(rq);
@@ -2845,7 +2848,7 @@ static void put_prev_task_dl(struct rq *rq, struct task_struct *p, struct task_s
28452848
if (task_is_blocked(p))
28462849
return;
28472850

2848-
if (on_dl_rq(&p->dl) && p->nr_cpus_allowed > 1)
2851+
if (on_dl_rq(dl_se) && p->nr_cpus_allowed > 1)
28492852
enqueue_pushable_dl_task(rq, p);
28502853
}
28512854

0 commit comments

Comments
 (0)