From 7a8045dfd3b91c65e0b5beb967871559839b7a77 Mon Sep 17 00:00:00 2001 From: Tengfei Fan Date: Tue, 21 Apr 2020 09:01:51 +0800 Subject: [PATCH] sched/walt: Improve the scheduler This change is for general scheduler improvement. Change-Id: If03bf5f104740adf09d854837ae9b141dc97cbc6 Signed-off-by: Tengfei Fan [pkondeti@codeaurora: Added tunable based on priority] Signed-off-by: Pavankumar Kondeti --- include/linux/sched/sysctl.h | 1 + kernel/sched/fair.c | 6 ++++++ kernel/sched/sched.h | 6 ++++++ kernel/sysctl.c | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index cd531a27bdf1..d9a15434b2db 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -55,6 +55,7 @@ extern unsigned int __weak sysctl_sched_ravg_window_nr_ticks; extern unsigned int __weak sysctl_sched_many_wakeup_threshold; extern unsigned int __weak sysctl_sched_dynamic_ravg_window_enable; extern unsigned int sysctl_sched_prefer_spread; +extern unsigned int sysctl_walt_rtg_cfs_boost_prio; extern int walt_proc_group_thresholds_handler(struct ctl_table *table, int write, diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1f5911b12a65..3ad74eafc0c9 100755 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -133,6 +133,7 @@ unsigned int sched_capacity_margin_down[NR_CPUS] = { #ifdef CONFIG_SCHED_WALT __read_mostly unsigned int sysctl_sched_prefer_spread; +unsigned int sysctl_walt_rtg_cfs_boost_prio = 99; /* disabled by default */ #endif unsigned int sched_small_task_threshold = 102; @@ -4066,6 +4067,11 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) se->vruntime = min_vruntime(vruntime, se->vruntime); return; + } else if (task_rtg_high_prio(task_of(se))) { + vruntime -= thresh; + se->vruntime = min_vruntime(vruntime, + se->vruntime); + return; } #endif } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1e7f4813e5d7..60dd172bc943 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2991,6 +2991,12 @@ static inline bool task_in_related_thread_group(struct task_struct *p) return (rcu_access_pointer(p->wts.grp) != NULL); } +static inline bool task_rtg_high_prio(struct task_struct *p) +{ + return task_in_related_thread_group(p) && + (p->prio <= sysctl_walt_rtg_cfs_boost_prio); +} + static inline struct walt_related_thread_group *task_related_thread_group(struct task_struct *p) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ea162a9eb555..559147b4e88d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -150,6 +150,15 @@ const int sched_user_hint_max = 1000; static unsigned int ns_per_sec = NSEC_PER_SEC; static unsigned int one_hundred_thousand = 100000; static unsigned int two_hundred_million = 200000000; +/* + * CFS task prio range is [100 ... 139] + * 120 is the default prio. + * RTG boost range is [100 ... 119] because giving + * boost for [120 .. 139] does not make sense. + * 99 means disabled and it is the default value. + */ +static unsigned int min_cfs_boost_prio = 99; +static unsigned int max_cfs_boost_prio = 119; #endif /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ @@ -545,6 +554,15 @@ static struct ctl_table kern_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = &two, }, + { + .procname = "walt_rtg_cfs_boost_prio", + .data = &sysctl_walt_rtg_cfs_boost_prio, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &min_cfs_boost_prio, + .extra2 = &max_cfs_boost_prio, + }, #endif #ifdef CONFIG_SCHED_DEBUG {