Skip to content

Commit c85dbdd

Browse files
committed
sched/deadline: Move some utility functions to deadline.h
Some utility functions on sched_dl_entity can be useful outside of deadline.c , for instance for modelling, without relying on raw structure fields. Move functions like dl_task_of and dl_is_implicit to deadline.h to make them available outside. Acked-by: Juri Lelli <juri.lelli@redhat.com> Link: https://lore.kernel.org/r/20260330111010.153663-12-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
1 parent 820725b commit c85dbdd

2 files changed

Lines changed: 28 additions & 27 deletions

File tree

include/linux/sched/deadline.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,31 @@ extern void dl_clear_root_domain_cpu(int cpu);
3737
extern u64 dl_cookie;
3838
extern bool dl_bw_visited(int cpu, u64 cookie);
3939

40+
static inline bool dl_server(struct sched_dl_entity *dl_se)
41+
{
42+
return dl_se->dl_server;
43+
}
44+
45+
static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se)
46+
{
47+
BUG_ON(dl_server(dl_se));
48+
return container_of(dl_se, struct task_struct, dl);
49+
}
50+
51+
/*
52+
* Regarding the deadline, a task with implicit deadline has a relative
53+
* deadline == relative period. A task with constrained deadline has a
54+
* relative deadline <= relative period.
55+
*
56+
* We support constrained deadline tasks. However, there are some restrictions
57+
* applied only for tasks which do not have an implicit deadline. See
58+
* update_dl_entity() to know more about such restrictions.
59+
*
60+
* The dl_is_implicit() returns true if the task has an implicit deadline.
61+
*/
62+
static inline bool dl_is_implicit(struct sched_dl_entity *dl_se)
63+
{
64+
return dl_se->dl_deadline == dl_se->dl_period;
65+
}
66+
4067
#endif /* _LINUX_SCHED_DEADLINE_H */

kernel/sched/deadline.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <linux/cpuset.h>
2020
#include <linux/sched/clock.h>
21+
#include <linux/sched/deadline.h>
2122
#include <uapi/linux/sched/types.h>
2223
#include "sched.h"
2324
#include "pelt.h"
@@ -57,17 +58,6 @@ static int __init sched_dl_sysctl_init(void)
5758
late_initcall(sched_dl_sysctl_init);
5859
#endif /* CONFIG_SYSCTL */
5960

60-
static bool dl_server(struct sched_dl_entity *dl_se)
61-
{
62-
return dl_se->dl_server;
63-
}
64-
65-
static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se)
66-
{
67-
BUG_ON(dl_server(dl_se));
68-
return container_of(dl_se, struct task_struct, dl);
69-
}
70-
7161
static inline struct rq *rq_of_dl_rq(struct dl_rq *dl_rq)
7262
{
7363
return container_of(dl_rq, struct rq, dl);
@@ -990,22 +980,6 @@ update_dl_revised_wakeup(struct sched_dl_entity *dl_se, struct rq *rq)
990980
dl_se->runtime = (dl_se->dl_density * laxity) >> BW_SHIFT;
991981
}
992982

993-
/*
994-
* Regarding the deadline, a task with implicit deadline has a relative
995-
* deadline == relative period. A task with constrained deadline has a
996-
* relative deadline <= relative period.
997-
*
998-
* We support constrained deadline tasks. However, there are some restrictions
999-
* applied only for tasks which do not have an implicit deadline. See
1000-
* update_dl_entity() to know more about such restrictions.
1001-
*
1002-
* The dl_is_implicit() returns true if the task has an implicit deadline.
1003-
*/
1004-
static inline bool dl_is_implicit(struct sched_dl_entity *dl_se)
1005-
{
1006-
return dl_se->dl_deadline == dl_se->dl_period;
1007-
}
1008-
1009983
/*
1010984
* When a deadline entity is placed in the runqueue, its runtime and deadline
1011985
* might need to be updated. This is done by a CBS wake up rule. There are two

0 commit comments

Comments
 (0)