From b8176d18520146ee63d02cd9a8ee96ad76fb7d31 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Wed, 19 Feb 2020 14:24:15 +0530 Subject: [PATCH 1/3] sched: walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: I49218b594f77ab416c317e952865d889fd9a2058 Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/sched.h | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 6bd0fcbcab99..8b3ea4a9c1d4 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -89,7 +89,6 @@ extern unsigned int sched_capacity_margin_up[NR_CPUS]; extern unsigned int sched_capacity_margin_down[NR_CPUS]; struct sched_walt_cpu_load { - unsigned long prev_window_util; unsigned long nl; unsigned long pl; bool rtgb_active; From 79af30b00c268cc8920c62aa5ff649c15b7d4ad3 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Mon, 17 Feb 2020 11:35:03 +0530 Subject: [PATCH 2/3] sched: walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: I4623a59eca688209110c347d388df2a2839a6287 Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: resolve trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/sched.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 8b3ea4a9c1d4..5eef844e889a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3402,13 +3402,3 @@ extern struct task_struct *find_process_by_pid(pid_t pid); extern void enqueue_task_core(struct rq *rq, struct task_struct *p, int flags); extern void dequeue_task_core(struct rq *rq, struct task_struct *p, int flags); - -#ifdef CONFIG_SMP -static inline void sched_irq_work_queue(struct irq_work *work) -{ - if (likely(cpu_online(raw_smp_processor_id()))) - irq_work_queue(work); - else - irq_work_queue_on(work, cpumask_any(cpu_online_mask)); -} -#endif From 63466a35368a80dab5ee927616103d368d975c81 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Fri, 14 Feb 2020 15:09:42 -0800 Subject: [PATCH 3/3] sched: walt: Improve the scheduler This change is for general scheduler improvements. Change-Id: I325a7ae02d57260392029da240268d25f5823fe7 Signed-off-by: Abhijeet Dharmapurikar Signed-off-by: Satya Durga Srinivasu Prabhala --- drivers/base/arch_topology.c | 2 ++ include/linux/sched.h | 2 ++ kernel/sched/core.c | 2 -- kernel/sched/debug.c | 4 --- kernel/sched/sched.h | 53 +++++------------------------------- kernel/sched/walt.c | 1 + kernel/sched/walt.h | 3 -- 7 files changed, 12 insertions(+), 55 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index bbe3b0237773..5d3c28562487 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -20,6 +20,7 @@ #include #include #include +#include DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; DEFINE_PER_CPU(unsigned long, max_cpu_freq); @@ -219,6 +220,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, if (cpumask_empty(cpus_to_visit)) { topology_normalize_cpu_scale(); + walt_update_cluster_topology(); schedule_work(&update_topology_flags_work); free_raw_capacity(); pr_debug("cpu_capacity: parsing done\n"); diff --git a/include/linux/sched.h b/include/linux/sched.h index 83a3fc23dfea..5b68f8f56b60 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -549,6 +549,7 @@ sched_update_cpu_freq_min_max(const cpumask_t *cpus, u32 fmin, u32 fmax); extern void free_task_load_ptrs(struct task_struct *p); extern void sched_set_refresh_rate(enum fps fps); extern int set_task_boost(int boost, u64 period); +extern void walt_update_cluster_topology(void); #define RAVG_HIST_SIZE_MAX 5 #define NUM_BUSY_BUCKETS 10 @@ -618,6 +619,7 @@ static inline void sched_update_cpu_freq_min_max(const cpumask_t *cpus, static inline void sched_set_refresh_rate(enum fps fps) { } static inline void set_task_boost(int boost, u64 period) { } +static inline void walt_update_cluster_topology(void) { } #endif /* CONFIG_SCHED_WALT */ struct sched_rt_entity { diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7ce133447293..b3378fcbc66b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6755,8 +6755,6 @@ void __init sched_init_smp(void) sched_init_domains(cpu_active_mask); mutex_unlock(&sched_domains_mutex); - update_cluster_topology(); - /* Move init over to a non-isolated CPU */ if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0) BUG(); diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index d7959f96820f..f2ad08403249 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -650,11 +650,7 @@ do { \ P(cpu_capacity); #endif #ifdef CONFIG_SCHED_WALT - P(cluster->max_possible_capacity); - P(cluster->efficiency); P(cluster->cur_freq); - P(cluster->max_freq); - P(cluster->exec_scale_factor); P(walt_stats.nr_big_tasks); SEQ_printf(m, " .%-30s: %llu\n", "walt_stats.cumulative_runnable_avg", rq->walt_stats.cumulative_runnable_avg_scaled); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 5eef844e889a..ad1684bcb15e 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -128,19 +128,11 @@ struct sched_cluster { struct list_head list; struct cpumask cpus; int id; - int max_power_cost; - int min_power_cost; - int max_possible_capacity; - int efficiency; /* Differentiate cpus with different IPC capability */ - unsigned int exec_scale_factor; /* - * max_freq = user maximum - * max_mitigated_freq = thermal defined maximum * max_possible_freq = maximum supported by hardware */ - unsigned int cur_freq, max_freq, max_mitigated_freq, min_freq; + unsigned int cur_freq; unsigned int max_possible_freq; - bool freq_init_done; u64 aggr_grp_load; }; @@ -2900,13 +2892,8 @@ struct related_thread_group { extern struct sched_cluster *sched_cluster[NR_CPUS]; extern unsigned int __weak sched_disable_window_stats; -extern unsigned int max_possible_freq; -extern unsigned int min_max_freq; -extern unsigned int max_possible_efficiency; -extern unsigned int min_possible_efficiency; extern unsigned int max_possible_capacity; extern unsigned int __weak min_max_possible_capacity; -extern unsigned int max_power_cost; extern unsigned int __read_mostly __weak sched_init_task_load_windows; extern unsigned int __read_mostly __weak sched_load_granule; @@ -2959,29 +2946,15 @@ static inline bool asym_cap_sibling_group_has_capacity(int dst_cpu, int margin) return ((total_capacity * 100) > (total_util * margin)); } -static inline int cpu_max_possible_capacity(int cpu) +static inline unsigned int cpu_max_possible_freq(int cpu) { - return cpu_rq(cpu)->cluster->max_possible_capacity; -} - -static inline unsigned int cluster_max_freq(struct sched_cluster *cluster) -{ - /* - * Governor and thermal driver don't know the other party's mitigation - * voting. So struct cluster saves both and return min() for current - * cluster fmax. - */ - return min(cluster->max_mitigated_freq, cluster->max_freq); + return cpu_rq(cpu)->cluster->max_possible_freq; } static inline unsigned int cpu_max_freq(int cpu) { - return cluster_max_freq(cpu_rq(cpu)->cluster); -} - -static inline unsigned int cpu_max_possible_freq(int cpu) -{ - return cpu_rq(cpu)->cluster->max_possible_freq; + return mult_frac(cpu_max_possible_freq(cpu), capacity_orig_of(cpu), + arch_scale_cpu_capacity(cpu)); } static inline bool hmp_capable(void) @@ -2991,12 +2964,12 @@ static inline bool hmp_capable(void) static inline bool is_max_capacity_cpu(int cpu) { - return cpu_max_possible_capacity(cpu) == max_possible_capacity; + return arch_scale_cpu_capacity(cpu) == max_possible_capacity; } static inline bool is_min_capacity_cpu(int cpu) { - return cpu_max_possible_capacity(cpu) == min_max_possible_capacity; + return arch_scale_cpu_capacity(cpu) == min_max_possible_capacity; } static inline unsigned int task_load(struct task_struct *p) @@ -3144,11 +3117,6 @@ extern void sched_boost_parse_dt(void); extern void clear_ed_task(struct task_struct *p, struct rq *rq); extern bool early_detection_notify(struct rq *rq, u64 wallclock); -static inline unsigned int power_cost(int cpu, u64 demand) -{ - return cpu_max_possible_capacity(cpu); -} - void note_task_waking(struct task_struct *p, u64 wallclock); static inline bool task_placement_boost_enabled(struct task_struct *p) @@ -3322,13 +3290,6 @@ static inline bool early_detection_notify(struct rq *rq, u64 wallclock) return 0; } -#ifdef CONFIG_SMP -static inline unsigned int power_cost(int cpu, u64 demand) -{ - return SCHED_CAPACITY_SCALE; -} -#endif - static inline void note_task_waking(struct task_struct *p, u64 wallclock) { } #endif /* CONFIG_SCHED_WALT */ diff --git a/kernel/sched/walt.c b/kernel/sched/walt.c index f68e0a393451..df9a843c2e61 100644 --- a/kernel/sched/walt.c +++ b/kernel/sched/walt.c @@ -216,3 +216,4 @@ void __weak update_cluster_topology(void) { } void __weak init_clusters(void) { } void __weak walt_sched_init_rq(struct rq *rq) { } +void __weak walt_update_cluster_topology(void) { } diff --git a/kernel/sched/walt.h b/kernel/sched/walt.h index 594466d44f29..3fe0197a2672 100644 --- a/kernel/sched/walt.h +++ b/kernel/sched/walt.h @@ -133,8 +133,6 @@ static inline unsigned int max_task_load(void) return sched_ravg_window; } -extern void update_cluster_topology(void); - extern void init_clusters(void); extern void sched_account_irqtime(int cpu, struct task_struct *curr, @@ -226,7 +224,6 @@ static inline void sched_account_irqstart(int cpu, struct task_struct *curr, { } -static inline void update_cluster_topology(void) { } static inline void init_clusters(void) {} static inline void sched_account_irqtime(int cpu, struct task_struct *curr, u64 delta, u64 wallclock)