Loading include/linux/sched.h +1 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,7 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load); extern void sched_update_nr_prod(int cpu, long delta, bool inc); extern void sched_get_nr_running_avg(int *avg, int *iowait_avg, int *big_avg); extern u64 sched_get_cpu_last_busy_time(int cpu); extern void calc_global_load(unsigned long ticks); extern void update_cpu_load_nohz(void); Loading kernel/sched/qhmp_sched.h +3 −0 Original line number Diff line number Diff line Loading @@ -1027,6 +1027,9 @@ static inline int sched_cpu_high_irqload(int cpu) return sched_irqload(cpu) >= sysctl_sched_cpu_high_irqload; } static inline bool hmp_capable(void) { return false; } static inline bool is_min_capacity_cpu(int cpu) { return true; } #else /* CONFIG_SCHED_HMP */ struct hmp_sched_stats; Loading kernel/sched/sched.h +5 −0 Original line number Diff line number Diff line Loading @@ -1072,6 +1072,11 @@ static inline bool hmp_capable(void) return max_possible_capacity != min_max_possible_capacity; } static inline bool is_min_capacity_cpu(int cpu) { return cpu_max_possible_capacity(cpu) == min_max_possible_capacity; } /* * 'load' is in reference to "best cpu" at its best frequency. * Scale that in reference to a given cpu, accounting for how bad it is Loading kernel/sched/sched_avg.c +45 −1 Original line number Diff line number Diff line /* Copyright (c) 2012, 2015-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2012, 2015-2016, 2018 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -31,6 +31,8 @@ static DEFINE_PER_CPU(unsigned long, iowait_prod_sum); static DEFINE_PER_CPU(spinlock_t, nr_lock) = __SPIN_LOCK_UNLOCKED(nr_lock); static s64 last_get_time; static DEFINE_PER_CPU(atomic64_t, last_busy_time) = ATOMIC64_INIT(0); /** * sched_get_nr_running_avg * @return: Average nr_running, iowait and nr_big_tasks value since last poll. Loading Loading @@ -96,6 +98,41 @@ void sched_get_nr_running_avg(int *avg, int *iowait_avg, int *big_avg) } EXPORT_SYMBOL(sched_get_nr_running_avg); #define BUSY_NR_RUN 3 #define BUSY_LOAD_FACTOR 10 #ifdef CONFIG_SCHED_HMP static inline void update_last_busy_time(int cpu, bool dequeue, unsigned long prev_nr_run, u64 curr_time) { bool nr_run_trigger = false, load_trigger = false; if (!hmp_capable() || is_min_capacity_cpu(cpu)) return; if (prev_nr_run >= BUSY_NR_RUN && per_cpu(nr, cpu) < BUSY_NR_RUN) nr_run_trigger = true; if (dequeue) { u64 load; load = cpu_rq(cpu)->hmp_stats.cumulative_runnable_avg; load = scale_load_to_cpu(load, cpu); if (load * BUSY_LOAD_FACTOR > sched_ravg_window) load_trigger = true; } if (nr_run_trigger || load_trigger) atomic64_set(&per_cpu(last_busy_time, cpu), curr_time); } #else static inline void update_last_busy_time(int cpu, bool dequeue, unsigned long prev_nr_run, u64 curr_time) { } #endif /** * sched_update_nr_prod * @cpu: The core id of the nr running driver. Loading @@ -121,9 +158,16 @@ void sched_update_nr_prod(int cpu, long delta, bool inc) BUG_ON((s64)per_cpu(nr, cpu) < 0); update_last_busy_time(cpu, !inc, nr_running, curr_time); per_cpu(nr_prod_sum, cpu) += nr_running * diff; per_cpu(nr_big_prod_sum, cpu) += nr_eligible_big_tasks(cpu) * diff; per_cpu(iowait_prod_sum, cpu) += nr_iowait_cpu(cpu) * diff; spin_unlock_irqrestore(&per_cpu(nr_lock, cpu), flags); } EXPORT_SYMBOL(sched_update_nr_prod); u64 sched_get_cpu_last_busy_time(int cpu) { return atomic64_read(&per_cpu(last_busy_time, cpu)); } Loading
include/linux/sched.h +1 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,7 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load); extern void sched_update_nr_prod(int cpu, long delta, bool inc); extern void sched_get_nr_running_avg(int *avg, int *iowait_avg, int *big_avg); extern u64 sched_get_cpu_last_busy_time(int cpu); extern void calc_global_load(unsigned long ticks); extern void update_cpu_load_nohz(void); Loading
kernel/sched/qhmp_sched.h +3 −0 Original line number Diff line number Diff line Loading @@ -1027,6 +1027,9 @@ static inline int sched_cpu_high_irqload(int cpu) return sched_irqload(cpu) >= sysctl_sched_cpu_high_irqload; } static inline bool hmp_capable(void) { return false; } static inline bool is_min_capacity_cpu(int cpu) { return true; } #else /* CONFIG_SCHED_HMP */ struct hmp_sched_stats; Loading
kernel/sched/sched.h +5 −0 Original line number Diff line number Diff line Loading @@ -1072,6 +1072,11 @@ static inline bool hmp_capable(void) return max_possible_capacity != min_max_possible_capacity; } static inline bool is_min_capacity_cpu(int cpu) { return cpu_max_possible_capacity(cpu) == min_max_possible_capacity; } /* * 'load' is in reference to "best cpu" at its best frequency. * Scale that in reference to a given cpu, accounting for how bad it is Loading
kernel/sched/sched_avg.c +45 −1 Original line number Diff line number Diff line /* Copyright (c) 2012, 2015-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2012, 2015-2016, 2018 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -31,6 +31,8 @@ static DEFINE_PER_CPU(unsigned long, iowait_prod_sum); static DEFINE_PER_CPU(spinlock_t, nr_lock) = __SPIN_LOCK_UNLOCKED(nr_lock); static s64 last_get_time; static DEFINE_PER_CPU(atomic64_t, last_busy_time) = ATOMIC64_INIT(0); /** * sched_get_nr_running_avg * @return: Average nr_running, iowait and nr_big_tasks value since last poll. Loading Loading @@ -96,6 +98,41 @@ void sched_get_nr_running_avg(int *avg, int *iowait_avg, int *big_avg) } EXPORT_SYMBOL(sched_get_nr_running_avg); #define BUSY_NR_RUN 3 #define BUSY_LOAD_FACTOR 10 #ifdef CONFIG_SCHED_HMP static inline void update_last_busy_time(int cpu, bool dequeue, unsigned long prev_nr_run, u64 curr_time) { bool nr_run_trigger = false, load_trigger = false; if (!hmp_capable() || is_min_capacity_cpu(cpu)) return; if (prev_nr_run >= BUSY_NR_RUN && per_cpu(nr, cpu) < BUSY_NR_RUN) nr_run_trigger = true; if (dequeue) { u64 load; load = cpu_rq(cpu)->hmp_stats.cumulative_runnable_avg; load = scale_load_to_cpu(load, cpu); if (load * BUSY_LOAD_FACTOR > sched_ravg_window) load_trigger = true; } if (nr_run_trigger || load_trigger) atomic64_set(&per_cpu(last_busy_time, cpu), curr_time); } #else static inline void update_last_busy_time(int cpu, bool dequeue, unsigned long prev_nr_run, u64 curr_time) { } #endif /** * sched_update_nr_prod * @cpu: The core id of the nr running driver. Loading @@ -121,9 +158,16 @@ void sched_update_nr_prod(int cpu, long delta, bool inc) BUG_ON((s64)per_cpu(nr, cpu) < 0); update_last_busy_time(cpu, !inc, nr_running, curr_time); per_cpu(nr_prod_sum, cpu) += nr_running * diff; per_cpu(nr_big_prod_sum, cpu) += nr_eligible_big_tasks(cpu) * diff; per_cpu(iowait_prod_sum, cpu) += nr_iowait_cpu(cpu) * diff; spin_unlock_irqrestore(&per_cpu(nr_lock, cpu), flags); } EXPORT_SYMBOL(sched_update_nr_prod); u64 sched_get_cpu_last_busy_time(int cpu) { return atomic64_read(&per_cpu(last_busy_time, cpu)); }