mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
sched: Scale down cpu_power due to RT tasks
Keep an average on the amount of time spend on RT tasks and use that fraction to scale down the cpu_power for regular tasks. Signed-off-by: Peter Zijlstra <[email protected]> Tested-by: Andreas Herrmann <[email protected]> Acked-by: Andreas Herrmann <[email protected]> Acked-by: Gautham R Shenoy <[email protected]> Cc: Balbir Singh <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
ab29230e67
commit
e9e9250bc7
4 changed files with 72 additions and 7 deletions
|
|
@ -627,6 +627,9 @@ struct rq {
|
|||
|
||||
struct task_struct *migration_thread;
|
||||
struct list_head migration_queue;
|
||||
|
||||
u64 rt_avg;
|
||||
u64 age_stamp;
|
||||
#endif
|
||||
|
||||
/* calc_load related fields */
|
||||
|
|
@ -862,6 +865,14 @@ unsigned int sysctl_sched_shares_ratelimit = 250000;
|
|||
*/
|
||||
unsigned int sysctl_sched_shares_thresh = 4;
|
||||
|
||||
/*
|
||||
* period over which we average the RT time consumption, measured
|
||||
* in ms.
|
||||
*
|
||||
* default: 1s
|
||||
*/
|
||||
const_debug unsigned int sysctl_sched_time_avg = MSEC_PER_SEC;
|
||||
|
||||
/*
|
||||
* period over which we measure -rt task cpu usage in us.
|
||||
* default: 1s
|
||||
|
|
@ -1280,12 +1291,37 @@ void wake_up_idle_cpu(int cpu)
|
|||
}
|
||||
#endif /* CONFIG_NO_HZ */
|
||||
|
||||
static u64 sched_avg_period(void)
|
||||
{
|
||||
return (u64)sysctl_sched_time_avg * NSEC_PER_MSEC / 2;
|
||||
}
|
||||
|
||||
static void sched_avg_update(struct rq *rq)
|
||||
{
|
||||
s64 period = sched_avg_period();
|
||||
|
||||
while ((s64)(rq->clock - rq->age_stamp) > period) {
|
||||
rq->age_stamp += period;
|
||||
rq->rt_avg /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
|
||||
{
|
||||
rq->rt_avg += rt_delta;
|
||||
sched_avg_update(rq);
|
||||
}
|
||||
|
||||
#else /* !CONFIG_SMP */
|
||||
static void resched_task(struct task_struct *p)
|
||||
{
|
||||
assert_spin_locked(&task_rq(p)->lock);
|
||||
set_tsk_need_resched(p);
|
||||
}
|
||||
|
||||
static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
|
|
@ -3699,7 +3735,7 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
|
|||
}
|
||||
#endif /* CONFIG_SCHED_MC || CONFIG_SCHED_SMT */
|
||||
|
||||
unsigned long __weak arch_smt_gain(struct sched_domain *sd, int cpu)
|
||||
unsigned long __weak arch_scale_smt_power(struct sched_domain *sd, int cpu)
|
||||
{
|
||||
unsigned long weight = cpumask_weight(sched_domain_span(sd));
|
||||
unsigned long smt_gain = sd->smt_gain;
|
||||
|
|
@ -3709,6 +3745,24 @@ unsigned long __weak arch_smt_gain(struct sched_domain *sd, int cpu)
|
|||
return smt_gain;
|
||||
}
|
||||
|
||||
unsigned long scale_rt_power(int cpu)
|
||||
{
|
||||
struct rq *rq = cpu_rq(cpu);
|
||||
u64 total, available;
|
||||
|
||||
sched_avg_update(rq);
|
||||
|
||||
total = sched_avg_period() + (rq->clock - rq->age_stamp);
|
||||
available = total - rq->rt_avg;
|
||||
|
||||
if (unlikely((s64)total < SCHED_LOAD_SCALE))
|
||||
total = SCHED_LOAD_SCALE;
|
||||
|
||||
total >>= SCHED_LOAD_SHIFT;
|
||||
|
||||
return div_u64(available, total);
|
||||
}
|
||||
|
||||
static void update_cpu_power(struct sched_domain *sd, int cpu)
|
||||
{
|
||||
unsigned long weight = cpumask_weight(sched_domain_span(sd));
|
||||
|
|
@ -3719,11 +3773,15 @@ static void update_cpu_power(struct sched_domain *sd, int cpu)
|
|||
/* here we could scale based on cpufreq */
|
||||
|
||||
if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
|
||||
power *= arch_smt_gain(sd, cpu);
|
||||
power *= arch_scale_smt_power(sd, cpu);
|
||||
power >>= SCHED_LOAD_SHIFT;
|
||||
}
|
||||
|
||||
/* here we could scale based on RT time */
|
||||
power *= scale_rt_power(cpu);
|
||||
power >>= SCHED_LOAD_SHIFT;
|
||||
|
||||
if (!power)
|
||||
power = 1;
|
||||
|
||||
if (power != old) {
|
||||
sdg->__cpu_power = power;
|
||||
|
|
|
|||
Loading…
Reference in a new issue