Skip to content

Commit 9e07d45

Browse files
author
Peter Zijlstra
committed
sched/deadline: Collect sched_dl_entity initialization
Create a single function that initializes a sched_dl_entity. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Phil Auld <pauld@redhat.com> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Link: https://lkml.kernel.org/r/51acc695eecf0a1a2f78f9a044e11ffd9b316bcf.1699095159.git.bristot@kernel.org
1 parent c708a4d commit 9e07d45

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

kernel/sched/core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4511,10 +4511,7 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
45114511
memset(&p->stats, 0, sizeof(p->stats));
45124512
#endif
45134513

4514-
RB_CLEAR_NODE(&p->dl.rb_node);
4515-
init_dl_task_timer(&p->dl);
4516-
init_dl_inactive_task_timer(&p->dl);
4517-
__dl_clear_params(p);
4514+
init_dl_entity(&p->dl);
45184515

45194516
INIT_LIST_HEAD(&p->rt.run_list);
45204517
p->rt.timeout = 0;

kernel/sched/deadline.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ static void dl_change_utilization(struct task_struct *p, u64 new_bw)
335335
__add_rq_bw(new_bw, &rq->dl);
336336
}
337337

338+
static void __dl_clear_params(struct sched_dl_entity *dl_se);
339+
338340
/*
339341
* The utilization of a task cannot be immediately removed from
340342
* the rq active utilization (running_bw) when the task blocks.
@@ -434,7 +436,7 @@ static void task_non_contending(struct task_struct *p)
434436
raw_spin_lock(&dl_b->lock);
435437
__dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p)));
436438
raw_spin_unlock(&dl_b->lock);
437-
__dl_clear_params(p);
439+
__dl_clear_params(dl_se);
438440
}
439441

440442
return;
@@ -1183,7 +1185,7 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer)
11831185
return HRTIMER_NORESTART;
11841186
}
11851187

1186-
void init_dl_task_timer(struct sched_dl_entity *dl_se)
1188+
static void init_dl_task_timer(struct sched_dl_entity *dl_se)
11871189
{
11881190
struct hrtimer *timer = &dl_se->dl_timer;
11891191

@@ -1389,7 +1391,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer)
13891391
raw_spin_lock(&dl_b->lock);
13901392
__dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p)));
13911393
raw_spin_unlock(&dl_b->lock);
1392-
__dl_clear_params(p);
1394+
__dl_clear_params(dl_se);
13931395

13941396
goto unlock;
13951397
}
@@ -1405,7 +1407,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer)
14051407
return HRTIMER_NORESTART;
14061408
}
14071409

1408-
void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se)
1410+
static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se)
14091411
{
14101412
struct hrtimer *timer = &dl_se->inactive_timer;
14111413

@@ -2957,10 +2959,8 @@ bool __checkparam_dl(const struct sched_attr *attr)
29572959
/*
29582960
* This function clears the sched_dl_entity static params.
29592961
*/
2960-
void __dl_clear_params(struct task_struct *p)
2962+
static void __dl_clear_params(struct sched_dl_entity *dl_se)
29612963
{
2962-
struct sched_dl_entity *dl_se = &p->dl;
2963-
29642964
dl_se->dl_runtime = 0;
29652965
dl_se->dl_deadline = 0;
29662966
dl_se->dl_period = 0;
@@ -2978,6 +2978,14 @@ void __dl_clear_params(struct task_struct *p)
29782978
#endif
29792979
}
29802980

2981+
void init_dl_entity(struct sched_dl_entity *dl_se)
2982+
{
2983+
RB_CLEAR_NODE(&dl_se->rb_node);
2984+
init_dl_task_timer(dl_se);
2985+
init_dl_inactive_task_timer(dl_se);
2986+
__dl_clear_params(dl_se);
2987+
}
2988+
29812989
bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr)
29822990
{
29832991
struct sched_dl_entity *dl_se = &p->dl;

kernel/sched/sched.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ struct rt_bandwidth {
273273
unsigned int rt_period_active;
274274
};
275275

276-
void __dl_clear_params(struct task_struct *p);
277-
278276
static inline int dl_bandwidth_enabled(void)
279277
{
280278
return sysctl_sched_rt_runtime >= 0;
@@ -2427,8 +2425,7 @@ extern struct rt_bandwidth def_rt_bandwidth;
24272425
extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime);
24282426
extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
24292427

2430-
extern void init_dl_task_timer(struct sched_dl_entity *dl_se);
2431-
extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se);
2428+
extern void init_dl_entity(struct sched_dl_entity *dl_se);
24322429

24332430
#define BW_SHIFT 20
24342431
#define BW_UNIT (1 << BW_SHIFT)

0 commit comments

Comments
 (0)