sched/tune: don't use schedtune before it is ready

When EAS is enabled during boot, we have to be careful not to use
schedtune from fair.c before it is ready or it will warn us and we'll
get a traceback in the console.

Change-Id: I1a5cf29b18af626545c636c51219f9ed497c19fa
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
This commit is contained in:
Chris Redpath 2017-03-27 18:20:20 +01:00 committed by Andres Oportus
parent 9e3c04bef7
commit c47d00b57b
2 changed files with 15 additions and 2 deletions

View file

@ -5597,7 +5597,7 @@ static inline int __energy_diff(struct energy_env *eenv)
#ifdef CONFIG_SCHED_TUNE
struct target_nrg schedtune_target_nrg;
extern bool schedtune_initialized;
/*
* System energy normalization
* Returns the normalized value, in the range [0..SCHED_CAPACITY_SCALE],
@ -5607,13 +5607,20 @@ static inline int
normalize_energy(int energy_diff)
{
u32 normalized_nrg;
/* during early setup, we don't know the extents */
if (unlikely(!schedtune_initialized))
return energy_diff < 0 ? -1 : 1 ;
#ifdef CONFIG_SCHED_DEBUG
{
int max_delta;
/* Check for boundaries */
max_delta = schedtune_target_nrg.max_power;
max_delta -= schedtune_target_nrg.min_power;
WARN_ON(abs(energy_diff) >= max_delta);
}
#endif
/* Do scaling using positive numbers to increase the range */

View file

@ -12,7 +12,7 @@
#include "tune.h"
#ifdef CONFIG_CGROUP_SCHEDTUNE
static bool schedtune_initialized = false;
bool schedtune_initialized = false;
#endif
unsigned int sysctl_sched_cfs_boost __read_mostly;
@ -527,6 +527,9 @@ int schedtune_task_boost(struct task_struct *p)
struct schedtune *st;
int task_boost;
if (!unlikely(schedtune_initialized))
return 0;
/* Get task boost value */
rcu_read_lock();
st = task_schedtune(p);
@ -541,6 +544,9 @@ int schedtune_prefer_idle(struct task_struct *p)
struct schedtune *st;
int prefer_idle;
if (!unlikely(schedtune_initialized))
return 0;
/* Get prefer_idle value */
rcu_read_lock();
st = task_schedtune(p);