OSDN Git Service

sched/{fair,tune}: use reciprocal_value to compute boost margin
authorPatrick Bellasi <patrick.bellasi@arm.com>
Thu, 13 Oct 2016 16:31:24 +0000 (17:31 +0100)
committerAndres Oportus <andresoportus@google.com>
Fri, 2 Jun 2017 15:01:55 +0000 (08:01 -0700)
Change-Id: I493b07360c46eee0b72c2a046dab9ec6cb3427ef
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: Srinath Sridharan <srinathsr@google.com>
kernel/sched/fair.c
kernel/sched/tune.c

index 752d7dd..cc00d92 100644 (file)
@@ -5805,6 +5805,8 @@ static bool cpu_overutilized(int cpu)
 
 #ifdef CONFIG_SCHED_TUNE
 
+struct reciprocal_value schedtune_spc_rdiv;
+
 static long
 schedtune_margin(unsigned long signal, long boost)
 {
@@ -5815,29 +5817,16 @@ schedtune_margin(unsigned long signal, long boost)
         *
         * The Boost (B) value is used to compute a Margin (M) which is
         * proportional to the complement of the original Signal (S):
-        *   M = B * (SCHED_LOAD_SCALE - S), if B is positive
-        *   M = B * S, if B is negative
+        *   M = B * (SCHED_CAPACITY_SCALE - S)
         * The obtained M could be used by the caller to "boost" S.
         */
        if (boost >= 0) {
-               margin  = SCHED_LOAD_SCALE - signal;
+               margin  = SCHED_CAPACITY_SCALE - signal;
                margin *= boost;
        } else
                margin = -signal * boost;
-       /*
-        * Fast integer division by constant:
-        *  Constant   :                 (C) = 100
-        *  Precision  : 0.1%            (P) = 0.1
-        *  Reference  : C * 100 / P     (R) = 100000
-        *
-        * Thus:
-        *  Shift bits : ceil(log(R,2))  (S) = 17
-        *  Mult const : round(2^S/C)    (M) = 1311
-        *
-        *
-        */
-       margin  *= 1311;
-       margin >>= 17;
+
+       margin  = reciprocal_divide(margin, schedtune_spc_rdiv);
 
        if (boost < 0)
                margin *= -1;
index 5e81aaa..4935648 100644 (file)
@@ -17,6 +17,7 @@ static bool schedtune_initialized = false;
 
 unsigned int sysctl_sched_cfs_boost __read_mostly;
 
+extern struct reciprocal_value schedtune_spc_rdiv;
 extern struct target_nrg schedtune_target_nrg;
 
 /* Performance Boost region (B) threshold params */
@@ -937,6 +938,8 @@ schedtune_init(void)
        pr_info("schedtune: configured to support global boosting only\n");
 #endif
 
+       schedtune_spc_rdiv = reciprocal_value(100);
+
        return 0;
 
 nodata: