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

Commit 94c4cea6 authored by Morten Rasmussen's avatar Morten Rasmussen Committed by Dmitry Shmidt
Browse files

ANDROID: sched: Make energy awareness a sched feature



This patch introduces the ENERGY_AWARE sched feature, which is
implemented using jump labels when SCHED_DEBUG is defined. It is
statically set false when SCHED_DEBUG is not defined. Hence this doesn't
allow energy awareness to be enabled without SCHED_DEBUG. This
sched_feature knob will be replaced later with a more appropriate
control knob when things have matured a bit.

ENERGY_AWARE is based on per-entity load-tracking hence FAIR_GROUP_SCHED
must be enable. This dependency isn't checked at compile time yet.

cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarMorten Rasmussen <morten.rasmussen@arm.com>
Signed-off-by: default avatarAndres Oportus <andresoportus@google.com>
parent 577dacab
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1067,6 +1067,22 @@ struct sched_domain_attr {

extern int sched_domain_level_max;

struct capacity_state {
	unsigned long cap;	/* compute capacity */
	unsigned long power;	/* power consumption at this compute capacity */
};

struct idle_state {
	unsigned long power;	 /* power consumption in this idle state */
};

struct sched_group_energy {
	unsigned int nr_idle_states;	/* number of idle states */
	struct idle_state *idle_states;	/* ptr to idle state array */
	unsigned int nr_cap_states;	/* number of capacity states */
	struct capacity_state *cap_states; /* ptr to capacity state array */
};

struct sched_group;

struct sched_domain_shared {
@@ -1174,6 +1190,8 @@ bool cpus_share_cache(int this_cpu, int that_cpu);

typedef const struct cpumask *(*sched_domain_mask_f)(int cpu);
typedef int (*sched_domain_flags_f)(void);
typedef
const struct sched_group_energy * const(*sched_domain_energy_f)(int cpu);

#define SDTL_OVERLAP	0x01

@@ -1187,6 +1205,7 @@ struct sd_data {
struct sched_domain_topology_level {
	sched_domain_mask_f mask;
	sched_domain_flags_f sd_flags;
	sched_domain_energy_f energy;
	int		    flags;
	int		    numa_level;
	struct sd_data      data;
+5 −0
Original line number Diff line number Diff line
@@ -5104,6 +5104,11 @@ static void record_wakee(struct task_struct *p)
	}
}

static inline bool energy_aware(void)
{
	return sched_feat(ENERGY_AWARE);
}

/*
 * Detect M:N waker/wakee relationships via a switching-frequency heuristic.
 *
+5 −0
Original line number Diff line number Diff line
@@ -69,3 +69,8 @@ SCHED_FEAT(RT_RUNTIME_SHARE, true)
SCHED_FEAT(LB_MIN, false)
SCHED_FEAT(ATTACH_AGE_LOAD, true)

/*
 * Energy aware scheduling. Use platform energy model to guide scheduling
 * decisions optimizing for energy efficiency.
 */
SCHED_FEAT(ENERGY_AWARE, false)
+1 −0
Original line number Diff line number Diff line
@@ -905,6 +905,7 @@ struct sched_group {

	unsigned int group_weight;
	struct sched_group_capacity *sgc;
	const struct sched_group_energy const *sge;

	/*
	 * The CPUs this group covers.