From cd5ecacb5b3db89fdd8d243787741b402c7091c5 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Thu, 22 Sep 2022 15:42:38 -0700 Subject: [PATCH] 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 --- kernel/sched/walt/sysctl.c | 26 +++++++++++++++++++++++++- kernel/sched/walt/walt.h | 15 +++++---------- kernel/sched/walt/walt_cfs.c | 8 ++++++++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/kernel/sched/walt/sysctl.c b/kernel/sched/walt/sysctl.c index 896ee8fd6759..4762798ab7ee 100644 --- a/kernel/sched/walt/sysctl.c +++ b/kernel/sched/walt/sysctl.c @@ -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); diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index 37182af1feb0..3954933e7990 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -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)]; } } diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index e143c013c7e4..e88ba99b7bde 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -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) {