Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff198e03 authored by Olav Haugan's avatar Olav Haugan
Browse files

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: default avatarOlav Haugan <ohaugan@codeaurora.org>
parent c8df36dc
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2162,6 +2162,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)
@@ -2178,6 +2180,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);
+27 −0
Original line number Diff line number Diff line
@@ -800,6 +800,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) && \
@@ -9020,6 +9043,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);
+27 −0
Original line number Diff line number Diff line
@@ -800,6 +800,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) && \
@@ -8953,6 +8976,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);
+1 −0
Original line number Diff line number Diff line
@@ -617,6 +617,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;
+1 −0
Original line number Diff line number Diff line
@@ -626,6 +626,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;