sched/walt: use individual cpu early up/down threshold

Currently the code is using up/down thresholds based on clusters.
With number of clusters changing, it will be best if we populate
a per cpu value and use it.

Change-Id: Id16aef6f9cecb485fefe4d4e56f2b07852aa6e1c
Signed-off-by: Abhijeet Dharmapurikar <quic_adharmap@quicinc.com>
This commit is contained in:
Abhijeet Dharmapurikar 2022-09-22 15:42:38 -07:00 committed by Stephen Dickey
parent 87f1fd9d34
commit cd5ecacb5b
3 changed files with 38 additions and 11 deletions

View File

@ -454,6 +454,28 @@ int sched_updown_migrate_handler(struct ctl_table *table, int write,
return ret;
}
static void sched_update_updown_early_migrate_values(bool up)
{
int i = 0, cpu;
struct walt_sched_cluster *cluster;
for_each_sched_cluster(cluster) {
/*
* No need to worry about CPUs in last cluster
* if there are more than 2 clusters in the system
*/
for_each_cpu(cpu, &cluster->cpus) {
if (up)
sched_capacity_margin_early_up[cpu] = sysctl_sched_early_up[i];
else
sched_capacity_margin_early_down[cpu] = sysctl_sched_early_down[i];
}
if (++i >= num_sched_clusters - 1)
break;
}
}
int sched_updown_early_migrate_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
@ -490,7 +512,7 @@ int sched_updown_early_migrate_handler(struct ctl_table *table, int write,
}
}
/* check up pct is greater than dn pct */
/* check up thresh is greater than dn thresh */
if (data == &sysctl_sched_early_up[0]) {
for (i = 0; i < cap_margin_levels; i++) {
if (val[i] >= sysctl_sched_early_down[i]) {
@ -511,6 +533,8 @@ int sched_updown_early_migrate_handler(struct ctl_table *table, int write,
for (i = 0; i < cap_margin_levels; i++)
data[i] = val[i];
/* update individual cpu thresholds */
sched_update_updown_early_migrate_values(data == &sysctl_sched_early_up[0]);
unlock_mutex:
mutex_unlock(&mutex);

View File

@ -769,8 +769,9 @@ static bool check_for_higher_capacity(int cpu1, int cpu2)
return capacity_orig_of(cpu1) > capacity_orig_of(cpu2);
}
extern unsigned int sysctl_sched_early_up[MAX_MARGIN_LEVELS];
extern unsigned int sysctl_sched_early_down[MAX_MARGIN_LEVELS];
/* Migration margins for topapp */
extern unsigned int sched_capacity_margin_early_up[WALT_NR_CPUS];
extern unsigned int sched_capacity_margin_early_down[WALT_NR_CPUS];
static inline bool task_fits_capacity(struct task_struct *p,
int dst_cpu)
{
@ -783,18 +784,12 @@ static inline bool task_fits_capacity(struct task_struct *p,
if (check_for_higher_capacity(task_cpu(p), dst_cpu)) {
margin = sched_capacity_margin_down[dst_cpu];
if (task_in_related_thread_group(p)) {
if (is_min_cluster_cpu(dst_cpu))
margin = sysctl_sched_early_down[0];
else if (!is_max_cluster_cpu(dst_cpu))
margin = sysctl_sched_early_down[1];
margin = sched_capacity_margin_early_down[dst_cpu];
}
} else {
margin = sched_capacity_margin_up[task_cpu(p)];
if (task_in_related_thread_group(p)) {
if (is_min_cluster_cpu(task_cpu(p)))
margin = sysctl_sched_early_up[0];
else if (!is_max_cluster_cpu(task_cpu(p)))
margin = sysctl_sched_early_up[1];
margin = sched_capacity_margin_early_up[task_cpu(p)];
}
}

View File

@ -61,6 +61,14 @@ unsigned int sched_capacity_margin_down[WALT_NR_CPUS] = {
[0 ... WALT_NR_CPUS-1] = 1205 /* ~15% margin */
};
/* Migration margins for topapp */
unsigned int sched_capacity_margin_early_up[WALT_NR_CPUS] = {
[0 ... WALT_NR_CPUS-1] = 1078 /* ~5% margin */
};
unsigned int sched_capacity_margin_early_down[WALT_NR_CPUS] = {
[0 ... WALT_NR_CPUS-1] = 1205 /* ~15% margin */
};
static inline bool
bias_to_this_cpu(struct task_struct *p, int cpu, int start_cpu)
{