From 4735599f5108fa574b577084b39d0ac05c4abdf2 Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Thu, 18 Nov 2021 11:56:55 -0800 Subject: [PATCH] sched: Remove references to min/max capacity cpus Adapt the min/max capacity cpu helper functions to use cluster IDs to guide decisions rather than capacities. Change-Id: Ic204f286c8eb95742ab64d366ce30d5ee780c340 Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/core_ctl.c | 2 +- kernel/sched/walt/cpufreq_walt.c | 2 +- kernel/sched/walt/walt.c | 19 ++++++++++--------- kernel/sched/walt/walt.h | 29 ++++++++++++++++------------- kernel/sched/walt/walt_cfs.c | 3 +-- kernel/sched/walt/walt_lb.c | 8 ++++---- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/kernel/sched/walt/core_ctl.c b/kernel/sched/walt/core_ctl.c index 7d48cb0ec4bf..9d36748fccf8 100644 --- a/kernel/sched/walt/core_ctl.c +++ b/kernel/sched/walt/core_ctl.c @@ -784,7 +784,7 @@ static bool adjustment_possible(const struct cluster_data *cluster, static bool need_all_cpus(const struct cluster_data *cluster) { - return (is_min_capacity_cpu(cluster->first_cpu) && + return (is_min_cluster_cpu(cluster->first_cpu) && sched_ravg_window < DEFAULT_SCHED_RAVG_WINDOW); } diff --git a/kernel/sched/walt/cpufreq_walt.c b/kernel/sched/walt/cpufreq_walt.c index 377f0602c91e..53125b982600 100644 --- a/kernel/sched/walt/cpufreq_walt.c +++ b/kernel/sched/walt/cpufreq_walt.c @@ -306,7 +306,7 @@ static inline unsigned long target_util(struct waltgov_policy *wg_policy, util = freq_to_util(wg_policy, freq); - if (wg_policy->max == min_max_possible_capacity && + if (is_min_cluster_cpu(wg_policy->policy->cpu) && util >= wg_policy->tunables->target_load_thresh) util = mult_frac(util, 94, 100); else diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index de375ca6f537..8c0b909da209 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -64,8 +64,8 @@ unsigned int walt_rotation_enabled; cpumask_t asym_cap_sibling_cpus = CPU_MASK_NONE; unsigned int __read_mostly sched_ravg_window = 20000000; -unsigned int min_max_possible_capacity = 1024; -unsigned int max_possible_capacity = 1024; /* max(rq->max_possible_capacity) */ +int min_possible_cluster_id; +int max_possible_cluster_id; /* Initial task load. Newly created tasks are assigned this load. */ unsigned int __read_mostly sched_init_task_load_windows; /* @@ -271,8 +271,7 @@ void walt_dump(void) sched_ravg_window_change_time); for_each_online_cpu(cpu) walt_rq_dump(cpu); - SCHED_PRINT(max_possible_capacity); - SCHED_PRINT(min_max_possible_capacity); + SCHED_PRINT(max_possible_cluster_id); printk_deferred("============ WALT RQ DUMP END ==============\n"); } @@ -2446,16 +2445,18 @@ static void update_all_clusters_stats(void) for_each_sched_cluster(cluster) { u64 mpc = arch_scale_cpu_capacity( cluster_first_cpu(cluster)); + int cluster_id = cluster->id; - if (mpc > highest_mpc) + if (mpc > highest_mpc) { highest_mpc = mpc; + max_possible_cluster_id = cluster_id; + } - if (mpc < lowest_mpc) + if (mpc < lowest_mpc) { lowest_mpc = mpc; + min_possible_cluster_id = cluster_id; + } } - - max_possible_capacity = highest_mpc; - min_max_possible_capacity = lowest_mpc; walt_update_group_thresholds(); } diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index 2d00aaee997f..79f7045e02ac 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -177,8 +177,8 @@ extern int core_ctl_init(void); extern atomic64_t walt_irq_work_lastq_ws; extern unsigned int __read_mostly sched_ravg_window; -extern unsigned int min_max_possible_capacity; -extern unsigned int max_possible_capacity; +extern int min_possible_cluster_id; +extern int max_possible_cluster_id; extern unsigned int __read_mostly sched_init_task_load_windows; extern unsigned int __read_mostly sched_load_granule; @@ -622,22 +622,26 @@ static inline int cluster_first_cpu(struct walt_sched_cluster *cluster) static inline bool hmp_capable(void) { - return max_possible_capacity != min_max_possible_capacity; + return max_possible_cluster_id != min_possible_cluster_id; } -static inline bool is_max_capacity_cpu(int cpu) +static inline bool is_max_cluster_cpu(int cpu) { - return arch_scale_cpu_capacity(cpu) == max_possible_capacity; + struct walt_rq *wrq = (struct walt_rq *) cpu_rq(cpu)->android_vendor_data1; + + return wrq->cluster->id == max_possible_cluster_id; } -static inline bool is_min_capacity_cpu(int cpu) +static inline bool is_min_cluster_cpu(int cpu) { - return arch_scale_cpu_capacity(cpu) == min_max_possible_capacity; + struct walt_rq *wrq = (struct walt_rq *) cpu_rq(cpu)->android_vendor_data1; + + return wrq->cluster->id == min_possible_cluster_id; } static inline bool is_min_capacity_cluster(struct walt_sched_cluster *cluster) { - return is_min_capacity_cpu(cluster_first_cpu(cluster)); + return cluster->id == min_possible_cluster_id; } /* @@ -696,7 +700,7 @@ static inline bool walt_should_kick_upmigrate(struct task_struct *p, int cpu) if (is_suh_max() && rtg && rtg->id == DEFAULT_CGROUP_COLOC_ID && rtg->skip_min && wts->unfilter) - return is_min_capacity_cpu(cpu); + return is_min_cluster_cpu(cpu); return false; } @@ -731,13 +735,12 @@ static inline bool task_fits_capacity(struct task_struct *p, static inline bool task_fits_max(struct task_struct *p, int cpu) { unsigned long capacity = capacity_orig_of(cpu); - unsigned long max_capacity = max_possible_capacity; unsigned long task_boost = per_task_boost(p); - if (capacity == max_capacity) + if (is_max_cluster_cpu(cpu)) return true; - if (is_min_capacity_cpu(cpu)) { + if (is_min_cluster_cpu(cpu)) { if (task_boost_policy(p) == SCHED_BOOST_ON_BIG || task_boost > 0 || walt_uclamp_boosted(p) || @@ -891,7 +894,7 @@ void walt_lb_tick(struct rq *rq); extern __read_mostly unsigned int walt_scale_demand_divisor; #define scale_demand(d) ((d)/walt_scale_demand_divisor) -#define ASYMCAP_BOOST(cpu) (sysctl_sched_asymcap_boost && !is_min_capacity_cpu(cpu)) +#define ASYMCAP_BOOST(cpu) (sysctl_sched_asymcap_boost && !is_min_cluster_cpu(cpu)) void create_util_to_cost(void); struct compute_energy_output { diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 3ab8b2a91ec0..a93bc35cbb2a 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -73,9 +73,8 @@ bias_to_this_cpu(struct task_struct *p, int cpu, int start_cpu) static inline bool task_demand_fits(struct task_struct *p, int cpu) { unsigned long capacity = capacity_orig_of(cpu); - unsigned long max_capacity = max_possible_capacity; - if (capacity == max_capacity) + if (is_max_cluster_cpu(cpu)) return true; return task_fits_capacity(p, capacity, cpu); diff --git a/kernel/sched/walt/walt_lb.c b/kernel/sched/walt/walt_lb.c index e0bfd5bab9e3..7e361c89e9f7 100644 --- a/kernel/sched/walt/walt_lb.c +++ b/kernel/sched/walt/walt_lb.c @@ -143,7 +143,7 @@ static void walt_lb_check_for_rotation(struct rq *src_rq) struct walt_lb_rotate_work *wr = NULL; struct walt_task_struct *wts; - if (!is_min_capacity_cpu(src_cpu)) + if (!is_min_cluster_cpu(src_cpu)) return; wc = walt_ktime_get_ns(); @@ -151,7 +151,7 @@ static void walt_lb_check_for_rotation(struct rq *src_rq) for_each_possible_cpu(i) { struct rq *rq = cpu_rq(i); - if (!is_min_capacity_cpu(i)) + if (!is_min_cluster_cpu(i)) break; if (is_reserved(i)) @@ -174,7 +174,7 @@ static void walt_lb_check_for_rotation(struct rq *src_rq) for_each_possible_cpu(i) { struct rq *rq = cpu_rq(i); - if (is_min_capacity_cpu(i)) + if (is_min_cluster_cpu(i)) continue; if (is_reserved(i)) @@ -723,7 +723,7 @@ static bool should_help_min_cap(int this_cpu) { int cpu; - if (!sysctl_sched_force_lb_enable || is_min_capacity_cpu(this_cpu)) + if (!sysctl_sched_force_lb_enable || is_min_cluster_cpu(this_cpu)) return false; for_each_cpu(cpu, &cpu_array[0][0]) {