Skip to content

Commit 72f9f3f

Browse files
Luca AbeniIngo Molnar
authored andcommitted
sched/deadline: Remove dl_new from struct sched_dl_entity
The dl_new field of struct sched_dl_entity is currently used to identify new deadline tasks, so that their deadline and runtime can be properly initialised. However, these tasks can be easily identified by checking if their deadline is smaller than the current time when they switch to SCHED_DEADLINE. So, dl_new can be removed by introducing this check in switched_to_dl(); this allows to simplify the SCHED_DEADLINE code. Signed-off-by: Luca Abeni <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent ca03174 commit 72f9f3f

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

include/linux/sched.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,18 +1333,14 @@ struct sched_dl_entity {
13331333
* task has to wait for a replenishment to be performed at the
13341334
* next firing of dl_timer.
13351335
*
1336-
* @dl_new tells if a new instance arrived. If so we must
1337-
* start executing it with full runtime and reset its absolute
1338-
* deadline;
1339-
*
13401336
* @dl_boosted tells if we are boosted due to DI. If so we are
13411337
* outside bandwidth enforcement mechanism (but only until we
13421338
* exit the critical section);
13431339
*
13441340
* @dl_yielded tells if task gave up the cpu before consuming
13451341
* all its available runtime during the last job.
13461342
*/
1347-
int dl_throttled, dl_new, dl_boosted, dl_yielded;
1343+
int dl_throttled, dl_boosted, dl_yielded;
13481344

13491345
/*
13501346
* Bandwidth enforcement timer. Each -deadline task has its

kernel/sched/core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,6 @@ void __dl_clear_params(struct task_struct *p)
20512051
dl_se->dl_bw = 0;
20522052

20532053
dl_se->dl_throttled = 0;
2054-
dl_se->dl_new = 1;
20552054
dl_se->dl_yielded = 0;
20562055
}
20572056

kernel/sched/deadline.c

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,15 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se,
352352
struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
353353
struct rq *rq = rq_of_dl_rq(dl_rq);
354354

355-
WARN_ON(!dl_se->dl_new || dl_se->dl_throttled);
355+
WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline));
356+
357+
/*
358+
* We are racing with the deadline timer. So, do nothing because
359+
* the deadline timer handler will take care of properly recharging
360+
* the runtime and postponing the deadline
361+
*/
362+
if (dl_se->dl_throttled)
363+
return;
356364

357365
/*
358366
* We use the regular wall clock time to set deadlines in the
@@ -361,7 +369,6 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se,
361369
*/
362370
dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;
363371
dl_se->runtime = pi_se->dl_runtime;
364-
dl_se->dl_new = 0;
365372
}
366373

367374
/*
@@ -503,15 +510,6 @@ static void update_dl_entity(struct sched_dl_entity *dl_se,
503510
struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
504511
struct rq *rq = rq_of_dl_rq(dl_rq);
505512

506-
/*
507-
* The arrival of a new instance needs special treatment, i.e.,
508-
* the actual scheduling parameters have to be "renewed".
509-
*/
510-
if (dl_se->dl_new) {
511-
setup_new_dl_entity(dl_se, pi_se);
512-
return;
513-
}
514-
515513
if (dl_time_before(dl_se->deadline, rq_clock(rq)) ||
516514
dl_entity_overflow(dl_se, pi_se, rq_clock(rq))) {
517515
dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;
@@ -607,16 +605,6 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer)
607605
goto unlock;
608606
}
609607

610-
/*
611-
* This is possible if switched_from_dl() raced against a running
612-
* callback that took the above !dl_task() path and we've since then
613-
* switched back into SCHED_DEADLINE.
614-
*
615-
* There's nothing to do except drop our task reference.
616-
*/
617-
if (dl_se->dl_new)
618-
goto unlock;
619-
620608
/*
621609
* The task might have been boosted by someone else and might be in the
622610
* boosting/deboosting path, its not throttled.
@@ -925,7 +913,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
925913
* parameters of the task might need updating. Otherwise,
926914
* we want a replenishment of its runtime.
927915
*/
928-
if (dl_se->dl_new || flags & ENQUEUE_WAKEUP)
916+
if (flags & ENQUEUE_WAKEUP)
929917
update_dl_entity(dl_se, pi_se);
930918
else if (flags & ENQUEUE_REPLENISH)
931919
replenish_dl_entity(dl_se, pi_se);
@@ -1726,6 +1714,9 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
17261714
*/
17271715
static void switched_to_dl(struct rq *rq, struct task_struct *p)
17281716
{
1717+
if (dl_time_before(p->dl.deadline, rq_clock(rq)))
1718+
setup_new_dl_entity(&p->dl, &p->dl);
1719+
17291720
if (task_on_rq_queued(p) && rq->curr != p) {
17301721
#ifdef CONFIG_SMP
17311722
if (p->nr_cpus_allowed > 1 && rq->dl.overloaded)

0 commit comments

Comments
 (0)