As all the sched_setscheduler*() exports have been removed, introduce
sched_set_deadline() on the model of sched_set_fifo() to enable modules
to create SCHED_DEADLINE tasks.

Signed-off-by: Quentin Perret <[email protected]>
---
 include/linux/sched.h |  2 ++
 kernel/sched/core.c   | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index c0da93a26f62..63c8ae7a0dd8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1630,6 +1630,8 @@ extern int sched_setscheduler_nocheck(struct task_struct 
*, int, const struct sc
 extern void sched_set_fifo(struct task_struct *p);
 extern void sched_set_fifo_low(struct task_struct *p);
 extern void sched_set_normal(struct task_struct *p, int nice);
+extern int sched_set_deadline(struct task_struct *p, u64 runtime, u64 deadline,
+                             u64 period, u64 flags);
 extern int sched_setattr(struct task_struct *, const struct sched_attr *);
 extern int sched_setattr_nocheck(struct task_struct *, const struct sched_attr 
*);
 extern struct task_struct *idle_task(int cpu);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7324f3b0f8d2..dbaf3f63df22 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5136,6 +5136,23 @@ void sched_set_normal(struct task_struct *p, int nice)
 }
 EXPORT_SYMBOL_GPL(sched_set_normal);
 
+int sched_set_deadline(struct task_struct *p, u64 runtime, u64 deadline,
+                      u64 period, u64 flags)
+{
+       struct sched_attr attr = {
+               .size           = sizeof(struct sched_attr),
+               .sched_policy   = SCHED_DEADLINE,
+               .sched_flags    = flags,
+               .sched_nice     = 0,
+               .sched_priority = 0,
+               .sched_runtime  = runtime,
+               .sched_deadline = deadline,
+               .sched_period   = period,
+       };
+       return sched_setattr_nocheck(p, &attr);
+}
+EXPORT_SYMBOL_GPL(sched_set_deadline);
+
 static int
 do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
 {
-- 
2.26.2.526.g744177e7f7-goog

Reply via email to