sched/tune: don't use schedtune before it is ready
authorChris Redpath <chris.redpath@arm.com>
Mon, 27 Mar 2017 17:20:20 +0000 (18:20 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 21 Jun 2017 11:07:49 +0000 (16:37 +0530)
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>
kernel/sched/fair.c
kernel/sched/tune.c

index ef4dc3281e2236ac7693a42fc8da49d2b749c3a7..226d1990eea95e137cbf15c605c31184c8d849a8 100644 (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 */
index 4935648166791e3e246479015a3d424fb63b4b68..86d04caf1684b4095c4c3dfbecc8c96fc13904f2 100644 (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);