diff options
author | Olav Haugan <ohaugan@codeaurora.org> | 2015-08-29 11:03:37 -0700 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 20:02:26 -0700 |
commit | 4996dafe6875f2804d525e6ac74162e3efc4cda3 (patch) | |
tree | 65627bed9bcf9ae4ab1ccb66a2d32067aab12989 | |
parent | b4627e0104c72dd25048fdcd8dd38fad78ad9782 (diff) |
sched/core: Add API to set cluster d-state
Add new API to the scheduler to allow low power mode driver to inform
the scheduler about the d-state of a cluster. This can be leveraged by
the scheduler to make an informed decision about the cost of placing a task
on a cluster.
Change-Id: If0fe0fdba7acad1c2eb73654ebccfdb421225e62
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
[joonwoop@codeaurora.org: omitted fixes for qhmp_core.c and qhmp_core.h]
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
-rw-r--r-- | include/linux/sched.h | 7 | ||||
-rw-r--r-- | kernel/sched/core.c | 27 | ||||
-rw-r--r-- | kernel/sched/sched.h | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 941930f2935f..9e4171146f39 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2319,6 +2319,8 @@ extern int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask); extern void sched_set_cpu_cstate(int cpu, int cstate, int wakeup_energy, int wakeup_latency); +extern void sched_set_cluster_dstate(const cpumask_t *cluster_cpus, int dstate, + int wakeup_energy, int wakeup_latency); #else static inline void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) @@ -2335,6 +2337,11 @@ static inline void sched_set_cpu_cstate(int cpu, int cstate, int wakeup_energy, int wakeup_latency) { } + +static inline void sched_set_cluster_dstate(const cpumask_t *cluster_cpus, + int dstate, int wakeup_energy, int wakeup_latency) +{ +} #endif extern int sched_set_wake_up_idle(struct task_struct *p, int wake_up_idle); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cc3ba6ee00d8..1150d8665ac8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -787,6 +787,29 @@ sched_set_cpu_cstate(int cpu, int cstate, int wakeup_energy, int wakeup_latency) rq->wakeup_energy = wakeup_energy; rq->wakeup_latency = wakeup_latency; } + +/* + * Note D-state for (idle) cluster. + * + * @dstate = dstate index, 0 -> active state + * @wakeup_energy = energy spent in waking up cluster + * @wakeup_latency = latency to wakeup from cluster + * + */ +void sched_set_cluster_dstate(const cpumask_t *cluster_cpus, int dstate, + int wakeup_energy, int wakeup_latency) +{ + int cpu; + + for_each_cpu(cpu, cluster_cpus) { + struct rq *rq = cpu_rq(cpu); + + rq->dstate = dstate; + rq->dstate_wakeup_energy = wakeup_energy; + rq->dstate_wakeup_latency = wakeup_latency; + } +} + #endif /* CONFIG_SMP */ #if defined(CONFIG_RT_GROUP_SCHED) || (defined(CONFIG_FAIR_GROUP_SCHED) && \ @@ -9385,6 +9408,10 @@ void __init sched_init(void) rq->cstate = 0; rq->wakeup_latency = 0; + rq->dstate = 0; + rq->dstate_wakeup_latency = 0; + rq->dstate_wakeup_energy = 0; + INIT_LIST_HEAD(&rq->cfs_tasks); rq_attach_root(rq, &def_root_domain); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 2545fe83e8cd..4380cfacf1da 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -664,6 +664,7 @@ struct rq { u64 idle_stamp; u64 avg_idle; int cstate, wakeup_latency, wakeup_energy; + int dstate, dstate_wakeup_latency, dstate_wakeup_energy; /* This is used to determine avg_idle's max value */ u64 max_idle_balance_cost; |