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

Commit f7de9ee5 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

sched/walt: Improve the scheduler



This change is for general scheduler improvement.

Change-Id: I3af4fccd6db844729863f0422a910e2906c8ff9a
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent b8bfc1d9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -6319,7 +6319,6 @@ int sched_cpu_activate(unsigned int cpu)
	rq_unlock_irqrestore(rq, &rf);

	update_max_interval();
	walt_update_min_max_capacity();

	return 0;
}
@@ -6359,7 +6358,6 @@ int sched_cpu_deactivate(unsigned int cpu)
		return ret;
	}
	sched_domains_numa_masks_clear(cpu);
	walt_update_min_max_capacity();
	return 0;
}

+0 −3
Original line number Diff line number Diff line
@@ -675,7 +675,6 @@ do { \
#endif
#ifdef CONFIG_SCHED_WALT
	P(cluster->load_scale_factor);
	P(cluster->capacity);
	P(cluster->max_possible_capacity);
	P(cluster->efficiency);
	P(cluster->cur_freq);
@@ -765,8 +764,6 @@ static void sched_debug_header(struct seq_file *m)
	P(sysctl_sched_features);
#ifdef CONFIG_SCHED_WALT
	P(sched_init_task_load_windows);
	P(min_capacity);
	P(max_capacity);
	P(sched_ravg_window);
	P(sched_load_granule);
#endif
+1 −1
Original line number Diff line number Diff line
@@ -8623,7 +8623,7 @@ static int detach_tasks(struct lb_env *env)
	if (!same_cluster(env->dst_cpu, env->src_cpu))
		env->flags |= LBF_IGNORE_PREFERRED_CLUSTER_TASKS;

	if (cpu_capacity(env->dst_cpu) < cpu_capacity(env->src_cpu))
	if (capacity_orig_of(env->dst_cpu) < capacity_orig_of(env->src_cpu))
		env->flags |= LBF_IGNORE_BIG_TASKS;

redo:
+0 −74
Original line number Diff line number Diff line
@@ -130,7 +130,6 @@ struct sched_cluster {
	int max_power_cost;
	int min_power_cost;
	int max_possible_capacity;
	int capacity;
	int efficiency; /* Differentiate cpus with different IPC capability */
	int load_scale_factor;
	unsigned int exec_scale_factor;
@@ -2729,12 +2728,6 @@ enum sched_boost_policy {
	SCHED_BOOST_ON_ALL,
};

/*
 * Returns the rq capacity of any rq in a group. This does not play
 * well with groups where rq capacity can change independently.
 */
#define group_rq_capacity(group) cpu_capacity(group_first_cpu(group))

#ifdef CONFIG_SCHED_WALT

static inline int cluster_first_cpu(struct sched_cluster *cluster)
@@ -2764,8 +2757,6 @@ extern unsigned int max_possible_freq;
extern unsigned int min_max_freq;
extern unsigned int max_possible_efficiency;
extern unsigned int min_possible_efficiency;
extern unsigned int max_capacity;
extern unsigned int min_capacity;
extern unsigned int max_possible_capacity;
extern unsigned int min_max_possible_capacity;
extern unsigned int max_power_cost;
@@ -2793,11 +2784,6 @@ static inline int asym_cap_siblings(int cpu1, int cpu2)
		cpumask_test_cpu(cpu2, &asym_cap_sibling_cpus));
}

static inline int cpu_capacity(int cpu)
{
	return cpu_rq(cpu)->cluster->capacity;
}

static inline int cpu_max_possible_capacity(int cpu)
{
	return cpu_rq(cpu)->cluster->max_possible_capacity;
@@ -2828,24 +2814,6 @@ static inline unsigned int cpu_max_possible_freq(int cpu)
	return cpu_rq(cpu)->cluster->max_possible_freq;
}

/* Keep track of max/min capacity possible across CPUs "currently" */
static inline void __update_min_max_capacity(void)
{
	int i;
	int max_cap = 0, min_cap = INT_MAX;

	for_each_possible_cpu(i) {
		if (!cpu_active(i))
			continue;

		max_cap = max(max_cap, cpu_capacity(i));
		min_cap = min(min_cap, cpu_capacity(i));
	}

	max_capacity = max_cap;
	min_capacity = min_cap;
}

/*
 * Return load_scale_factor of a cpu in reference to "most" efficient cpu, so
 * that "most" efficient cpu gets a load_scale_factor of 1
@@ -2919,38 +2887,6 @@ static inline u64 scale_load_to_cpu(u64 task_load, int cpu)
	return task_load;
}

/*
 * Return 'capacity' of a cpu in reference to "least" efficient cpu, such that
 * least efficient cpu gets capacity of 1024
 */
static unsigned long
capacity_scale_cpu_efficiency(struct sched_cluster *cluster)
{
	return (1024 * cluster->efficiency) / min_possible_efficiency;
}

/*
 * Return 'capacity' of a cpu in reference to cpu with lowest max_freq
 * (min_max_freq), such that one with lowest max_freq gets capacity of 1024.
 */
static unsigned long capacity_scale_cpu_freq(struct sched_cluster *cluster)
{
	return (1024 * cluster_max_freq(cluster)) / min_max_freq;
}

static inline int compute_capacity(struct sched_cluster *cluster)
{
	int capacity = 1024;

	capacity *= capacity_scale_cpu_efficiency(cluster);
	capacity >>= 10;

	capacity *= capacity_scale_cpu_freq(cluster);
	capacity >>= 10;

	return capacity;
}

static inline unsigned int task_load(struct task_struct *p)
{
	return p->ravg.demand;
@@ -3132,8 +3068,6 @@ static inline enum sched_boost_policy task_boost_policy(struct task_struct *p)
	return policy;
}

extern void walt_update_min_max_capacity(void);

static inline bool is_min_capacity_cluster(struct sched_cluster *cluster)
{
	return is_min_capacity_cpu(cluster_first_cpu(cluster));
@@ -3205,13 +3139,6 @@ static inline u64 scale_load_to_cpu(u64 load, int cpu)
	return load;
}

#ifdef CONFIG_SMP
static inline int cpu_capacity(int cpu)
{
	return SCHED_CAPACITY_SCALE;
}
#endif

static inline void set_preferred_cluster(struct related_thread_group *grp) { }

static inline bool task_in_related_thread_group(struct task_struct *p)
@@ -3285,7 +3212,6 @@ static inline unsigned int power_cost(int cpu, u64 demand)
#endif

static inline void note_task_waking(struct task_struct *p, u64 wallclock) { }
static inline void walt_update_min_max_capacity(void) { }
#endif	/* CONFIG_SCHED_WALT */

struct sched_avg_stats {
+1 −21
Original line number Diff line number Diff line
@@ -149,9 +149,6 @@ unsigned int max_possible_freq = 1;
 * capacity (cpu_power) of cpus.
 */
unsigned int min_max_freq = 1;

unsigned int max_capacity = 1024; /* max(rq->capacity) */
unsigned int min_capacity = 1024; /* min(rq->capacity) */
unsigned int max_possible_capacity = 1024; /* max(rq->max_possible_capacity) */
unsigned int
min_max_possible_capacity = 1024; /* min(rq->max_possible_capacity) */
@@ -2121,7 +2118,6 @@ static struct sched_cluster *alloc_new_cluster(const struct cpumask *cpus)
	INIT_LIST_HEAD(&cluster->list);
	cluster->max_power_cost		=	1;
	cluster->min_power_cost		=	1;
	cluster->capacity		=	1024;
	cluster->max_possible_capacity	=	1024;
	cluster->efficiency		=	1;
	cluster->load_scale_factor	=	1024;
@@ -2164,7 +2160,7 @@ static int compute_max_possible_capacity(struct sched_cluster *cluster)
{
	int capacity = 1024;

	capacity *= capacity_scale_cpu_efficiency(cluster);
	capacity *= (1024 * cluster->efficiency) / min_possible_efficiency;
	capacity >>= 10;

	capacity *= (1024 * cluster->max_possible_freq) / min_max_freq;
@@ -2173,15 +2169,6 @@ static int compute_max_possible_capacity(struct sched_cluster *cluster)
	return capacity;
}

void walt_update_min_max_capacity(void)
{
	unsigned long flags;

	acquire_rq_locks_irqsave(cpu_possible_mask, &flags);
	__update_min_max_capacity();
	release_rq_locks_irqrestore(cpu_possible_mask, &flags);
}

unsigned int max_power_cost = 1;

static int
@@ -2249,7 +2236,6 @@ static void update_all_clusters_stats(void)
	for_each_sched_cluster(cluster) {
		u64 mpc;

		cluster->capacity = compute_capacity(cluster);
		mpc = cluster->max_possible_capacity =
			compute_max_possible_capacity(cluster);
		cluster->load_scale_factor = compute_load_scale_factor(cluster);
@@ -2269,7 +2255,6 @@ static void update_all_clusters_stats(void)
	min_max_possible_capacity = lowest_mpc;
	walt_update_group_thresholds();

	__update_min_max_capacity();
	release_rq_locks_irqrestore(cpu_possible_mask, &flags);
}

@@ -2314,7 +2299,6 @@ struct sched_cluster init_cluster = {
	.id			=	0,
	.max_power_cost		=	1,
	.min_power_cost		=	1,
	.capacity		=	1024,
	.max_possible_capacity	=	1024,
	.efficiency		=	1,
	.load_scale_factor	=	1024,
@@ -2349,8 +2333,6 @@ static int cpufreq_notifier_policy(struct notifier_block *nb,
	if (val != CPUFREQ_NOTIFY)
		return 0;

	walt_update_min_max_capacity();

	max_possible_freq = max(max_possible_freq, policy->cpuinfo.max_freq);
	if (min_max_freq == 1)
		min_max_freq = UINT_MAX;
@@ -2882,11 +2864,9 @@ void update_cpu_cluster_capacity(const cpumask_t *cpus)
		cluster = cpu_rq(i)->cluster;
		cpumask_andnot(&cpumask, &cpumask, &cluster->cpus);

		cluster->capacity = compute_capacity(cluster);
		cluster->load_scale_factor = compute_load_scale_factor(cluster);
	}

	__update_min_max_capacity();
	if (cpumask_intersects(cpus, &sched_cluster[0]->cpus))
		walt_update_group_thresholds();