From b1250b5cf67e82c7607a3989a475d96d2cfc5c74 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Sun, 19 Apr 2020 15:51:29 +0530 Subject: [PATCH 1/4] sched: Improve the scheduler This change is for general scheduler improvements. Change-Id: I3a220142f08a9664845b4d0e9918ec7c48bb11f7 Signed-off-by: Pavankumar Kondeti --- kernel/sched/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index aa2ec9f14431..b8dc34c5d0aa 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5650,7 +5650,7 @@ bool is_sched_lib_based_app(pid_t pid) char *libname, *lib_list; struct vm_area_struct *vma; char path_buf[LIB_PATH_LENGTH]; - char tmp_lib_name[LIB_PATH_LENGTH]; + char *tmp_lib_name; bool found = false; struct task_struct *p; struct mm_struct *mm; @@ -5658,11 +5658,16 @@ bool is_sched_lib_based_app(pid_t pid) if (strnlen(sched_lib_name, LIB_PATH_LENGTH) == 0) return false; + tmp_lib_name = kmalloc(LIB_PATH_LENGTH, GFP_KERNEL); + if (!tmp_lib_name) + return false; + rcu_read_lock(); p = find_process_by_pid(pid); if (!p) { rcu_read_unlock(); + kfree(tmp_lib_name); return false; } @@ -5700,6 +5705,7 @@ release_sem: mmput(mm); put_task_struct: put_task_struct(p); + kfree(tmp_lib_name); return found; } From d0a6a9b76764f9e8035bfc579c7cff3e763e060a Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Thu, 28 May 2020 11:46:29 +0530 Subject: [PATCH 2/4] sched/walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: I5f19453ec1a19c71d67a02c3f0ec9967e7673a4b Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: fix trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/fair.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1c8bc6618651..6564e4a039dd 100755 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6499,7 +6499,6 @@ enum fastpaths { NONE = 0, SYNC_WAKEUP, PREV_CPU_FASTPATH, - MANY_WAKEUP, }; static void walt_find_best_target(struct sched_domain *sd, cpumask_t *cpus, @@ -6950,6 +6949,9 @@ int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, bool boosted = is_uclamp_boosted || (task_boost > 0); int start_cpu, order_index, end_index; + if (walt_is_many_wakeup(sibling_count_hint) && prev_cpu != cpu && + cpumask_test_cpu(prev_cpu, &p->cpus_mask)) + return prev_cpu; if (unlikely(!cpu_array)) goto eas_not_ready; @@ -6979,13 +6981,6 @@ int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, goto done; } - if (walt_is_many_wakeup(sibling_count_hint) && prev_cpu != cpu && - bias_to_this_cpu(p, prev_cpu, start_cpu)) { - best_energy_cpu = prev_cpu; - fbt_env.fastpath = MANY_WAKEUP; - goto done; - } - rcu_read_lock(); pd = rcu_dereference(rd->pd); if (!pd) From 961c3a5fc3fb434e5528e4b0d4c96e65acf048b5 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Thu, 28 May 2020 11:46:29 +0530 Subject: [PATCH 3/4] sched/walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: Ica36bb6ccd4c2d8897dab62614eadb5a060d5390 Signed-off-by: Pavankumar Kondeti --- kernel/sched/core.c | 3 ++- kernel/sched/sched.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b8dc34c5d0aa..677768a0cb44 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2489,7 +2489,8 @@ static void ttwu_queue(struct task_struct *p, int cpu, int wake_flags) struct rq_flags rf; #if defined(CONFIG_SMP) - if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) { + if ((sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) || + walt_want_remote_wakeup()) { sched_clock_cpu(cpu); /* Sync clocks across CPUs */ ttwu_queue_remote(p, cpu, wake_flags); return; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 6aed1eaae23e..f4735f549917 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2859,6 +2859,12 @@ enum sched_boost_policy { #ifdef CONFIG_SCHED_WALT +#define WALT_MANY_WAKEUP_DEFAULT 1000 +static inline bool walt_want_remote_wakeup(void) +{ + return sysctl_sched_many_wakeup_threshold < WALT_MANY_WAKEUP_DEFAULT; +} + static inline int cluster_first_cpu(struct walt_sched_cluster *cluster) { return cpumask_first(&cluster->cpus); @@ -3268,6 +3274,10 @@ static inline bool early_detection_notify(struct rq *rq, u64 wallclock) } static inline void note_task_waking(struct task_struct *p, u64 wallclock) { } +static inline bool walt_want_remote_wakeup(void) +{ + return false; +} #endif /* CONFIG_SCHED_WALT */ struct sched_avg_stats { From 82fea0f9dcc75cdf7d126ed832ae25f872709f06 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Tue, 21 Apr 2020 07:52:28 +0530 Subject: [PATCH 4/4] sched/walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: I80606a09c3d09c65b7bcdf3940bee5e155d6318c Co-developed-by: Lingutla Chandrasekhar Signed-off-by: Lingutla Chandrasekhar Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: fix trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/sched.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f4735f549917..89f39b1bc7a3 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3002,7 +3002,6 @@ static inline int same_freq_domain(int src_cpu, int dst_cpu) #define CPU_RESERVED 1 extern enum sched_boost_policy __weak boost_policy; -extern unsigned int __weak sched_task_filter_util; static inline enum sched_boost_policy sched_boost_policy(void) { return boost_policy; @@ -3126,7 +3125,7 @@ static inline enum sched_boost_policy task_boost_policy(struct task_struct *p) * under conservative boost. */ if (sched_boost() == CONSERVATIVE_BOOST && - task_util(p) <= sched_task_filter_util) + task_util(p) <= sysctl_sched_min_task_util_for_boost) policy = SCHED_BOOST_NONE; }