sched: walt: Correct WALT window size initialization

It is preferable that WALT window rollover occurs just
before a tick, since the tick is an opportune moment
to record a complete window's statistics, as well as report
those stats to the cpu frequency governor. When CONFIG_HZ
results in a TICK_NSEC that isn't a integral number, this
requirement may be violated. Account for this by reducing
the WALT window size to the nearest multiple of TICK_NSEC.

Commit d368c6faa1 ("sched: walt: fix window misalignment
when HZ=300") attempted to do this but WALT isn't using
MIN_SCHED_RAVG_WINDOW as the window size and the patch was
doing nothing.

Also, change the type of 'walt_disabled' to bool and warn
if an invalid window size causes WALT to be disabled.

Change-Id: Ie3dcfc21a3df4408254ca1165a355bbe391ed5c7
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
This commit is contained in:
Vikram Mulukutla
2017-08-10 17:26:20 -07:00
committed by Joel Fernandes
parent 38ddcff85a
commit e79f447a97
4 changed files with 31 additions and 21 deletions

View File

@@ -642,7 +642,7 @@ TRACE_EVENT(sched_contrib_scale_f,
extern unsigned int sysctl_sched_use_walt_cpu_util;
extern unsigned int sysctl_sched_use_walt_task_util;
extern unsigned int walt_ravg_window;
extern unsigned int walt_disabled;
extern bool walt_disabled;
#endif
/*

View File

@@ -1560,7 +1560,7 @@ static inline unsigned long capacity_orig_of(int cpu)
extern unsigned int sysctl_sched_use_walt_cpu_util;
extern unsigned int walt_ravg_window;
extern unsigned int walt_disabled;
extern bool walt_disabled;
/*
* cpu_util returns the amount of capacity of a CPU that is used by CFS

View File

@@ -41,25 +41,17 @@ static __read_mostly unsigned int walt_io_is_busy = 0;
unsigned int sysctl_sched_walt_init_task_load_pct = 15;
/* 1 -> use PELT based load stats, 0 -> use window-based load stats */
unsigned int __read_mostly walt_disabled = 0;
/* true -> use PELT based load stats, false -> use window-based load stats */
bool __read_mostly walt_disabled = false;
/* Window size (in ns) */
__read_mostly unsigned int walt_ravg_window = 20000000;
/* Min window size (in ns) = 10ms */
#ifdef CONFIG_HZ_300
/*
* Tick interval becomes to 3333333 due to
* rounding error when HZ=300.
* Window size (in ns). Adjust for the tick size so that the window
* rollover occurs just before the tick boundary.
*/
#define MIN_SCHED_RAVG_WINDOW (3333333 * 6)
#else
#define MIN_SCHED_RAVG_WINDOW 10000000
#endif
/* Max window size (in ns) = 1s */
#define MAX_SCHED_RAVG_WINDOW 1000000000
__read_mostly unsigned int walt_ravg_window =
(20000000 / TICK_NSEC) * TICK_NSEC;
#define MIN_SCHED_RAVG_WINDOW ((10000000 / TICK_NSEC) * TICK_NSEC)
#define MAX_SCHED_RAVG_WINDOW ((1000000000 / TICK_NSEC) * TICK_NSEC)
static unsigned int sync_cpu;
static ktime_t ktime_last;
@@ -180,10 +172,28 @@ static int exiting_task(struct task_struct *p)
static int __init set_walt_ravg_window(char *str)
{
unsigned int adj_window;
bool no_walt = walt_disabled;
get_option(&str, &walt_ravg_window);
walt_disabled = (walt_ravg_window < MIN_SCHED_RAVG_WINDOW ||
walt_ravg_window > MAX_SCHED_RAVG_WINDOW);
/* Adjust for CONFIG_HZ */
adj_window = (walt_ravg_window / TICK_NSEC) * TICK_NSEC;
/* Warn if we're a bit too far away from the expected window size */
WARN(adj_window < walt_ravg_window - NSEC_PER_MSEC,
"tick-adjusted window size %u, original was %u\n", adj_window,
walt_ravg_window);
walt_ravg_window = adj_window;
walt_disabled = walt_disabled ||
(walt_ravg_window < MIN_SCHED_RAVG_WINDOW ||
walt_ravg_window > MAX_SCHED_RAVG_WINDOW);
WARN(!no_walt && walt_disabled,
"invalid window size, disabling WALT\n");
return 0;
}

View File

@@ -59,6 +59,6 @@ static inline u64 walt_ktime_clock(void) { return 0; }
#endif /* CONFIG_SCHED_WALT */
extern unsigned int walt_disabled;
extern bool walt_disabled;
#endif