ANDROID: sched/fair: Reduce balance interval to 1 jiffy if we have a misfit task

It is quite a common occurrence that we have a misfit task (a task
running on a CPU which is close to the capacity limit of that CPU)
in the system AND we have recently done a load balance operation.
Normal load-balance rate limiting means we can leave those tasks on
the restrictive CPU for a few hundred ms before we move them.

Inspired by the work Leo Yan did on balancing misfits.

This patch reduces the balance interval to one jiffy when there are such
tasks running.

There appears to be no impact on interactive performance from this
patch.

Change-Id: I71d74734d3bd6bca80476c0f466ba48914b7ac02
Signed-off-by: Chris Redpath <[email protected]>
Git-commit: 84c88fc37932db51b87af8df3cedc621cb5c6e97
Git-repo: https://android.googlesource.com/kernel/common
[[email protected]: Took only partial part from commit
  '84c88fc37932("ANDROID: Combined EAS Load Balance Tweaks")',
  and skip using 1 jiffy for busy balancing]
Signed-off-by: Lingutla Chandrasekhar <[email protected]>
This commit is contained in:
Chris Redpath 2017-10-28 18:38:04 +01:00 • committed by Gerrit - the friendly Code Review server
commit 512a9f267a

View file

@ -10261,6 +10261,9 @@ static inline unsigned long
get_sd_balance_interval(struct sched_domain *sd, int cpu_busy)
{
unsigned long interval = sd->balance_interval;
#ifdef CONFIG_SCHED_WALT
unsigned int cpu;
#endif
if (cpu_busy)
interval *= sd->busy_factor;
@ -10269,6 +10272,26 @@ get_sd_balance_interval(struct sched_domain *sd, int cpu_busy)
interval = msecs_to_jiffies(interval);
interval = clamp(interval, 1UL, max_load_balance_interval);
/*
* check if sched domain is marked as overutilized
* we ought to only do this on systems which have SD_ASYMCAPACITY
* but we want to do it for all sched domains in those systems
* So for now, just check if overutilized as a proxy.
*/
/*
* If we are overutilized and we have a misfit task, then
* we want to balance as soon as practically possible, so
* we return an interval of zero, except for busy balance.
*/
#ifdef CONFIG_SCHED_WALT
if (sd_overutilized(sd) && !cpu_busy) {
/* we know the root is overutilized, let's check for a misfit task */
for_each_cpu(cpu, sched_domain_span(sd)) {
if (cpu_rq(cpu)->misfit_task_load)
return 1;
}
}
#endif
return interval;
}