From e00ebdcb8a7ccc8c9da7206c63e7a880e10b37c0 Mon Sep 17 00:00:00 2001 From: Chris Redpath Date: Mon, 27 Mar 2017 18:20:20 +0100 Subject: [PATCH] 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 --- kernel/sched/fair.c | 9 ++++++++- kernel/sched/tune.c | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ef4dc3281e22..226d1990eea9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -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 */ diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 493564816679..86d04caf1684 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -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); -- 2.34.1