From 4dcd5a2a02a2de20e873f46a3b775d61de6ea2a9 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Wed, 5 May 2021 22:47:14 -0700 Subject: [PATCH] sched/walt: Improve the scheduler This change is for general scheduler improvement. Change-Id: I2a10a999f94e2f21eb97761516c135aadbe305e7 Signed-off-by: Abhijeet Dharmapurikar --- kernel/sched/walt/boost.c | 8 ++------ kernel/sched/walt/sched_avg.c | 2 +- kernel/sched/walt/walt.c | 10 +++------- kernel/sched/walt/walt.h | 29 +++++++++-------------------- kernel/sched/walt/walt_cfs.c | 2 +- 5 files changed, 16 insertions(+), 35 deletions(-) diff --git a/kernel/sched/walt/boost.c b/kernel/sched/walt/boost.c index ded1ce3d0ac5..eec2a5623987 100644 --- a/kernel/sched/walt/boost.c +++ b/kernel/sched/walt/boost.c @@ -14,8 +14,9 @@ * ended up with their load characteristics. Any entity enabling * boost is responsible for disabling it as well. */ +unsigned int sched_boost_type; +enum sched_boost_policy boost_policy; -static enum sched_boost_policy boost_policy_dt = SCHED_BOOST_NONE; static DEFINE_MUTEX(boost_mutex); void walt_init_tg(struct task_group *tg) @@ -75,11 +76,6 @@ static void set_boost_policy(int type) return; } - if (boost_policy_dt) { - boost_policy = boost_policy_dt; - return; - } - if (hmp_capable()) { boost_policy = SCHED_BOOST_ON_BIG; return; diff --git a/kernel/sched/walt/sched_avg.c b/kernel/sched/walt/sched_avg.c index 6bac78df55e7..d670148f80e7 100644 --- a/kernel/sched/walt/sched_avg.c +++ b/kernel/sched/walt/sched_avg.c @@ -115,7 +115,7 @@ void sched_update_hyst_times(void) int cpu; unsigned long cpu_cap, coloc_busy_pct; - rtgb_active = is_rtgb_active() && (sched_boost() != CONSERVATIVE_BOOST) + rtgb_active = is_rtgb_active() && (sched_boost_type != CONSERVATIVE_BOOST) && (get_rtgb_active_time() < MAX_RTGB_TIME); for_each_possible_cpu(cpu) { diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index 02bd142e11c1..9f892c525b63 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -60,8 +60,6 @@ static struct irq_work walt_cpufreq_irq_work; struct irq_work walt_migration_irq_work; unsigned int walt_rotation_enabled; cpumask_t asym_cap_sibling_cpus = CPU_MASK_NONE; -unsigned int sched_boost_type; -enum sched_boost_policy boost_policy; unsigned int __read_mostly sched_ravg_window = 20000000; unsigned int min_max_possible_capacity = 1024; @@ -441,8 +439,7 @@ static void update_task_cpu_cycles(struct task_struct *p, int cpu, static inline bool is_ed_enabled(void) { - return (walt_rotation_enabled || (sched_boost_policy() != - SCHED_BOOST_NONE)); + return (walt_rotation_enabled || (boost_policy != SCHED_BOOST_NONE)); } static inline bool is_ed_task(struct task_struct *p, u64 wallclock) @@ -3079,8 +3076,7 @@ static bool is_cluster_hosting_top_app(struct walt_sched_cluster *cluster) if (!grp) return false; - grp_on_min = !grp->skip_min && - (sched_boost_policy() != SCHED_BOOST_ON_BIG); + grp_on_min = !grp->skip_min && (boost_policy != SCHED_BOOST_ON_BIG); return (is_min_capacity_cluster(cluster) == grp_on_min); } @@ -3486,7 +3482,7 @@ void walt_rotation_checkpoint(int nr_big) if (!hmp_capable()) return; - if (!sysctl_sched_walt_rotate_big_tasks || sched_boost() != NO_BOOST) { + if (!sysctl_sched_walt_rotate_big_tasks || sched_boost_type != NO_BOOST) { walt_rotation_enabled = 0; return; } diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index ab3584f9e7a3..57f2affa53bc 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -404,25 +404,15 @@ static inline unsigned long cpu_util_cum(int cpu) return READ_ONCE(cpu_rq(cpu)->cfs.avg.util_avg); } -static inline enum sched_boost_policy sched_boost_policy(void) -{ - return boost_policy; -} - -static inline int sched_boost(void) -{ - return sched_boost_type; -} - static inline bool rt_boost_on_big(void) { - return sched_boost() == FULL_THROTTLE_BOOST ? - (sched_boost_policy() == SCHED_BOOST_ON_BIG) : false; + return sched_boost_type == FULL_THROTTLE_BOOST ? + (boost_policy == SCHED_BOOST_ON_BIG) : false; } static inline bool is_full_throttle_boost(void) { - return sched_boost() == FULL_THROTTLE_BOOST; + return sched_boost_type == FULL_THROTTLE_BOOST; } static inline bool task_sched_boost(struct task_struct *p) @@ -433,7 +423,7 @@ static inline bool task_sched_boost(struct task_struct *p) struct walt_task_group *wtg; /* optimization for FT boost, skip looking at tg */ - if (sched_boost() == FULL_THROTTLE_BOOST) + if (sched_boost_type == FULL_THROTTLE_BOOST) return true; rcu_read_lock(); @@ -444,7 +434,7 @@ static inline bool task_sched_boost(struct task_struct *p) } tg = container_of(css, struct task_group, css); wtg = (struct walt_task_group *) tg->android_vendor_data1; - sched_boost_enabled = wtg->sched_boost_enable[sched_boost()]; + sched_boost_enabled = wtg->sched_boost_enable[sched_boost_type]; rcu_read_unlock(); return sched_boost_enabled; @@ -452,7 +442,7 @@ static inline bool task_sched_boost(struct task_struct *p) static inline bool task_placement_boost_enabled(struct task_struct *p) { - if (likely(sched_boost_policy() == SCHED_BOOST_NONE)) + if (likely(boost_policy == SCHED_BOOST_NONE)) return false; return task_sched_boost(p); @@ -462,16 +452,16 @@ static inline enum sched_boost_policy task_boost_policy(struct task_struct *p) { enum sched_boost_policy policy; - if (likely(sched_boost_policy() == SCHED_BOOST_NONE)) + if (likely(boost_policy == SCHED_BOOST_NONE)) return SCHED_BOOST_NONE; - policy = task_sched_boost(p) ? sched_boost_policy() : SCHED_BOOST_NONE; + policy = task_sched_boost(p) ? boost_policy : SCHED_BOOST_NONE; if (policy == SCHED_BOOST_ON_BIG) { /* * Filter out tasks less than min task util threshold * under conservative boost. */ - if (sched_boost() == CONSERVATIVE_BOOST && + if (sched_boost_type == CONSERVATIVE_BOOST && task_util(p) <= sysctl_sched_min_task_util_for_boost) policy = SCHED_BOOST_NONE; } @@ -759,7 +749,6 @@ static inline unsigned int walt_get_idle_exit_latency(struct rq *rq) extern void sched_get_nr_running_avg(struct sched_avg_stats *stats); extern void sched_update_hyst_times(void); -extern enum sched_boost_policy sched_boost_policy(void); extern void walt_rt_init(void); extern void walt_cfs_init(void); extern void walt_pause_init(void); diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 990fe008a9d5..103fe55fbd92 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -96,7 +96,7 @@ static inline bool walt_task_skip_min_cpu(struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; - return sched_boost() != CONSERVATIVE_BOOST && + return (sched_boost_type != CONSERVATIVE_BOOST) && walt_get_rtg_status(p) && wts->unfilter; }