sched/deadline: Add start_new_instance helper
PATCH 1/1 sched/deadline: Add start_new_instance helper
Wrap repeated code in helper function start_new_instance, which set the deadline and runtiem of input dl_se based on pi_of(dl_se). Note that setup_new_dl_entity originally set the deadline and runtime base on dl_se, which should equals to pi_of(dl_se) for non-boosted task.
--- kernel/sched/deadline.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
kernel/sched/deadline.c +12 -10
@@ -770,6 +770,13 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags);static void __dequeue_task_dl (struct rq *rq,struct task_struct *p,int flags);static void check_preempt_curr_dl (struct rq *rq,struct task_struct *p,int flags); +static inline void start_new_instance (struct sched_dl_entity *dl_se,struct rq *rq) +{ +/* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; + dl_se->runtime =pi_of (dl_se)->dl_runtime; +} +/* * We are being explicitly informed that a new instance is starting, * and this means that:
@@ -803,8 +810,7 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)* future; in fact, we must consider execution overheads (time * spent on hardirq context, etc.). */ - dl_se->deadline =rq_clock (rq) + dl_se->dl_deadline; - dl_se->runtime = dl_se->dl_runtime; +start_new_instance (dl_se, rq); }/*
@@ -836,10 +842,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)* This could be the case for a !-dl task that is boosted. * Just go with full inherited parameters. */ -if (dl_se->dl_deadline ==0 ) { - dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; - dl_se->runtime =pi_of (dl_se)->dl_runtime; - } +if (dl_se->dl_deadline ==0 ) +start_new_instance (dl_se, rq);if (dl_se->dl_yielded && dl_se->runtime >0 ) dl_se->runtime =0 ;
@@ -866,8 +870,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)*/ if (dl_time_before (dl_se->deadline,rq_clock (rq))) {printk_deferred_once ("sched: DL replenish lagged too much\n" ); - dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; - dl_se->runtime =pi_of (dl_se)->dl_runtime; +start_new_instance (dl_se, rq); }if (dl_se->dl_yielded)
@@ -1024,8 +1027,7 @@ static void update_dl_entity(struct sched_dl_entity *dl_se)return ; } - dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; - dl_se->runtime =pi_of (dl_se)->dl_runtime; +start_new_instance (dl_se, rq); } }
Signature · 1 line
2.17.1
Quoted 2 lines · Shang XiaoJing
Wrap repeated code in helper function
start_new_instance, which set the deadline and runtiem of inputdl_sebased onpi_of(dl_se). Note that
^ runtime
Quoted 13 lines
setup_new_dl_entityoriginally set the deadline and runtime base ondl_se, which should equals topi_of(dl_se)for non-boosted task.Signed-off-by Shang XiaoJing <[email protected]>--- kernel/sched/deadline.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)kernel/sched/deadline.c +0
-0
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 771
Quoted 2 lines
kernel/sched/deadline.c +0
-0@@ -770,6 +770,13 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags);static void __dequeue_task_dl (struct rq *rq,struct task_struct *p,int flags);static void check_preempt_curr_dl (struct rq *rq,struct task_struct *p,int flags);
again, this is not a good function name. Maybe, dl_replenish_new_period() ?
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 779
Quoted 7 lines
kernel/sched/deadline.c +7
-0+static inline void start_new_instance (struct sched_dl_entity *dl_se,struct rq *rq) +{ +/* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; + dl_se->runtime =pi_of (dl_se)->dl_runtime; +} +
-- Daniel
Quoted 4 lines · Daniel Bristot de Oliveira
Quoted 2 lines · Shang XiaoJing
Wrap repeated code in helper function
start_new_instance, which set the deadline and runtiem of inputdl_sebased onpi_of(dl_se). Note that^ runtime
oops
Quoted 8 lines
Quoted 8 lines
setup_new_dl_entityoriginally set the deadline and runtime base ondl_se, which should equals topi_of(dl_se)for non-boosted task.Signed-off-by Shang XiaoJing <[email protected]>--- kernel/sched/deadline.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
Quoted 8 lines
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 771
Quoted 7 lines
kernel/sched/deadline.c +0
-0@@ -770,6 +770,13 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags);static void __dequeue_task_dl (struct rq *rq,struct task_struct *p,int flags);static void check_preempt_curr_dl (struct rq *rq,struct task_struct *p,int flags);again, this is not a good function name. Maybe,
dl_replenish_new_period()?
right, i have thought like replenish_new_instance, but when i'm making patch, i was worried that "replenish" is only for ENQUEUE_REPLENISH.
what about dl_start_new_period? which means a new deadline will be set, rather than
dl_se->deadline += pi_of(dl_se)->dl_period;
in replenish_dl_entity.
Quoted 8 lines
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 779
Quoted 7 lines
kernel/sched/deadline.c +7
-0+static inline void start_new_instance (struct sched_dl_entity *dl_se,struct rq *rq) +{ +/* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline =rq_clock (rq) +pi_of (dl_se)->dl_deadline; + dl_se->runtime =pi_of (dl_se)->dl_runtime; +} +-- Daniel
Thanks,
Shang XiaoJing
Quoted 4 lines · shangxiaojing
Quoted 1 line
again, this is not a good function name. Maybe, dl_replenish_new_period() ?
right, i have thought like
replenish_new_instance, but when i'm making patch, i was worried that "replenish" is only for ENQUEUE_REPLENISH.
I see, but that is a flag, not the action.
Quoted 1 line
what about
dl_start_new_period? which means a new deadline will be set, rather than
The thing it is doing is replenishing...
Quoted 3 lines
dl_se->deadline += pi_of(dl_se)->dl_period;
in replenish_dl_entity.
that is why I added "new_period".... so replenish_dl_new_period() to keep the consistency.
Quoted 9 lines
Quoted 9 lines
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 779
Quoted 8 lines
kernel/sched/deadline.c +7
-0+static inline void start_new_instance(struct sched_dl_entity *dl_se, struct rq *rq) +{ + /* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; + dl_se->runtime = pi_of(dl_se)->dl_runtime; +} +-- Daniel
-- Daniel
Quoted 6 lines · Daniel Bristot de Oliveira
Quoted 3 lines · shangxiaojing
Quoted 1 line
again, this is not a good function name. Maybe, dl_replenish_new_period() ?
right, i have thought like
replenish_new_instance, but when i'm making patch, i was worried that "replenish" is only for ENQUEUE_REPLENISH.I see, but that is a flag, not the action.
Quoted 7 lines
Quoted 1 line
what about
dl_start_new_period? which means a new deadline will be set, rather thanThe thing it is doing is replenishing...
Quoted 3 lines
dl_se->deadline += pi_of(dl_se)->dl_period;
in replenish_dl_entity.
that is why I added "
new_period".... soreplenish_dl_new_period()to keep the consistency.
ok, i'll use replenish_dl_new_period in v2.
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
kernel/sched/deadline.c static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); · line 779
Quoted 8 lines
kernel/sched/deadline.c +7
-0+static inline void start_new_instance(struct sched_dl_entity *dl_se, struct rq *rq) +{ + /* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; + dl_se->runtime = pi_of(dl_se)->dl_runtime; +} +-- Daniel
-- Daniel
Thanks,
Shang XiaoJing