diff --git a/include/linux/sched/walt.h b/include/linux/sched/walt.h index 12c93451f85a..bb636d930aad 100644 --- a/include/linux/sched/walt.h +++ b/include/linux/sched/walt.h @@ -38,13 +38,7 @@ enum task_boost_type { }; #define WALT_NR_CPUS 8 -/* - * RAVG_HIST_SHIFT trick can only be used if RAVG_HIST_SIZE is a power of 2. - */ #define RAVG_HIST_SIZE 8 -#define RAVG_HIST_SHIFT 3 -#define RAVG_HIST_MASK (RAVG_HIST_SIZE - 1) - /* wts->bucket_bitmask needs to be updated if NUM_BUSY_BUCKETS > 16 */ #define NUM_BUSY_BUCKETS 16 #define NUM_BUSY_BUCKETS_SHIFT 4 diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index da36b06cabae..ab43e0820bc2 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -2071,7 +2071,7 @@ static void update_history(struct rq *rq, struct task_struct *p, for (; samples > 0; samples--) { hist[wts->cidx] = runtime; hist_util[wts->cidx] = runtime_scaled; - wts->cidx = ++(wts->cidx) & RAVG_HIST_MASK; + wts->cidx = ++(wts->cidx) % RAVG_HIST_SIZE; } for (i = 0; i < RAVG_HIST_SIZE; i++) { @@ -2087,7 +2087,7 @@ static void update_history(struct rq *rq, struct task_struct *p, } else if (sysctl_sched_window_stats_policy == WINDOW_STATS_MAX) { demand = max; } else { - avg = sum >> RAVG_HIST_SHIFT; + avg = div64_u64(sum, RAVG_HIST_SIZE); if (sysctl_sched_window_stats_policy == WINDOW_STATS_AVG) demand = avg; else @@ -2116,7 +2116,7 @@ static void update_history(struct rq *rq, struct task_struct *p, wts->demand = demand; wts->demand_scaled = demand_scaled; - wts->coloc_demand = sum >> RAVG_HIST_SHIFT; + wts->coloc_demand = div64_u64(sum, RAVG_HIST_SIZE); wts->pred_demand_scaled = pred_demand_scaled; if (demand_scaled > sysctl_sched_min_task_util_for_colocation)