summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2018-12-27 14:32:16 +0100
committerDaniel Lezcano <daniel.lezcano@linaro.org>2018-12-27 15:51:37 +0100
commitf225f5170898f202c6d538431417d835d00c2a60 (patch)
treeffc2f982e17e2c1327fa1b0ec302b8e117fa56a0
parenteca8b839d92c150a57963547867251b4a8614d9b (diff)
sched: Return next idle task scheduling out deadline
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--include/linux/sched.h1
-rw-r--r--kernel/sched/core.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 291a9bd5b97f..fbdf4d65d703 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1540,6 +1540,7 @@ static inline int task_nice(const struct task_struct *p)
extern int can_nice(const struct task_struct *p, const int nice);
extern int task_curr(const struct task_struct *p);
extern int idle_cpu(int cpu);
+extern u64 idle_next_wakeup(void);
extern int available_idle_cpu(int cpu);
extern int sched_setscheduler(struct task_struct *, int, const struct sched_param *);
extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6fedf3a98581..87fde6568be4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2135,6 +2135,21 @@ int wake_up_state(struct task_struct *p, unsigned int state)
return try_to_wake_up(p, state, 0);
}
+u64 idle_next_wakeup(void)
+{
+ struct rq *rq = this_rq();
+
+ /*
+ * We can only call this function from the idle task context
+ * because it relies on the idle_stamp field which is set to
+ * zero otherwise.
+ */
+ if (WARN_ON_ONCE(!(current->flags & PF_IDLE)))
+ return U64_MAX;
+
+ return rq->idle_stamp + rq->avg_idle;
+}
+
/*
* Perform scheduler related setup for a newly forked process p.
* p is forked by current.