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

Commit 01388ef4 authored by Joonwoo Park's avatar Joonwoo Park
Browse files

sched: EAS: decouple capacity margin



Current consolidated capacity_margin is used by frequency guidance
as well as task placement.  This makes impossible to utilize little
CPU more than capacity margin as all the tasks which have more than
the margin will be upmigrated even if the task fits in little CPU.

Decouple capacity_margin into capacity_margin for CPU frequency
guidance and task placement.  We want to have higher margin for
former and lower margin for latter to raise frequency and account
task demand.

Also, introduce capacity_margin_down which controls down migration
threshold.  With single capacity_margin tipping point, any task
which is at the capacity margin can oscillate between little and big
cluster.

Change-Id: I3651b2bb800335807fc6472676bf29cd357df303
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
parent 9cf7f360
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3255,10 +3255,12 @@ unsigned long long task_sched_runtime(struct task_struct *p)

#ifdef CONFIG_CPU_FREQ_GOV_SCHED

unsigned int capacity_margin_freq = 1280; /* ~20% margin */

static inline
unsigned long add_capacity_margin(unsigned long cpu_capacity)
{
	cpu_capacity  = cpu_capacity * capacity_margin;
	cpu_capacity  = cpu_capacity * capacity_margin_freq;
	cpu_capacity /= SCHED_CAPACITY_SCALE;
	return cpu_capacity;
}
@@ -3285,7 +3287,7 @@ static void sched_freq_tick_pelt(int cpu)
	 * To make free room for a task that is building up its "real"
	 * utilization and to harm its performance the least, request
	 * a jump to a higher OPP as soon as the margin of free capacity
	 * is impacted (specified by capacity_margin).
	 * is impacted (specified by capacity_margin_freq).
	 */
	set_cfs_cpu_capacity(cpu, true, cpu_utilization);
}
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ void update_cpu_capacity_request(int cpu, bool request)
		new_capacity = scr->cfs + scr->rt;
#endif
	new_capacity = scr->cfs;
	new_capacity = new_capacity * capacity_margin
	new_capacity = new_capacity * capacity_margin_freq
		/ SCHED_CAPACITY_SCALE;
	new_capacity += scr->dl;

+9 −3
Original line number Diff line number Diff line
@@ -217,7 +217,8 @@ unsigned int sysctl_sched_cfs_bandwidth_slice = 5000UL;
 * The margin used when comparing utilization with CPU capacity:
 * util * 1024 < capacity * margin
 */
unsigned int capacity_margin = 1280; /* ~20% */
unsigned int capacity_margin = 1078; /* ~5% margin */
unsigned int capacity_margin_down = 1205; /* ~15% margin */

static inline void update_load_add(struct load_weight *lw, unsigned long inc)
{
@@ -5870,11 +5871,16 @@ static inline unsigned long boosted_task_util(struct task_struct *task);

static inline bool __task_fits(struct task_struct *p, int cpu, int util)
{
	unsigned long capacity = capacity_of(cpu);
	unsigned int margin;

	util += boosted_task_util(p);

	return (capacity * 1024) > (util * capacity_margin);
	if (capacity_orig_of(task_cpu(p)) > capacity_orig_of(cpu))
		margin = capacity_margin_down;
	else
		margin = capacity_margin;

	return (capacity_of(cpu) * 1024) > (util * margin);
}

static inline bool task_fits_max(struct task_struct *p, int cpu)
+1 −1
Original line number Diff line number Diff line
@@ -1784,7 +1784,7 @@ cpu_util_freq(int cpu, struct sched_walt_cpu_load *walt_load)

#ifdef CONFIG_CPU_FREQ_GOV_SCHED
#define capacity_max SCHED_CAPACITY_SCALE
extern unsigned int capacity_margin;
extern unsigned int capacity_margin_freq;
extern struct static_key __sched_freq;

static inline bool sched_freq(void)