sched: fair: Add support to PELT ramp/decay timings
authorlakkyung.jung <lakkyung.jung@samsung.com>
Tue, 24 Apr 2018 14:02:12 +0000 (23:02 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:58:59 +0000 (14:58 +0900)
Change-Id: If12dd8b4df211c898667cdb7c8b42d0eba9ac200
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: lakkyung.jung <lakkyung.jung@samsung.com>
Documentation/scheduler/sched-pelt.c
init/Kconfig
kernel/sched/sched-pelt.h

index e4219139386ae805575a7c1cae5dc83f5b3e52ca..13845882240c341831caf675b0b72b9a3ce1bc5a 100644 (file)
 #include <math.h>
 #include <stdio.h>
 
-#define HALFLIFE 32
+#define HALFLIFE { 32, 16, 8 }
 #define SHIFT 32
 
 double y;
 
-void calc_runnable_avg_yN_inv(void)
+void calc_runnable_avg_yN_inv(const int halflife)
 {
        int i;
        unsigned int x;
 
        printf("static const u32 runnable_avg_yN_inv[] = {");
-       for (i = 0; i < HALFLIFE; i++) {
+       for (i = 0; i < halflife; i++) {
                x = ((1UL<<32)-1)*pow(y, i);
 
-               if (i % 6 == 0) printf("\n\t");
+               if (i % 4 == 0) printf("\n\t");
                printf("0x%8x, ", x);
        }
        printf("\n};\n\n");
@@ -32,12 +32,12 @@ void calc_runnable_avg_yN_inv(void)
 
 int sum = 1024;
 
-void calc_runnable_avg_yN_sum(void)
+void calc_runnable_avg_yN_sum(const int halflife)
 {
        int i;
 
        printf("static const u32 runnable_avg_yN_sum[] = {\n\t    0,");
-       for (i = 1; i <= HALFLIFE; i++) {
+       for (i = 1; i <= halflife; i++) {
                if (i == 1)
                        sum *= y;
                else
@@ -55,7 +55,7 @@ int n = -1;
 /* first period */
 long max = 1024;
 
-void calc_converged_max(void)
+void calc_converged_max(const int halflife)
 {
        long last = 0, y_inv = ((1UL<<32)-1)*y;
 
@@ -73,17 +73,17 @@ void calc_converged_max(void)
                last = max;
        }
        n--;
-       printf("#define LOAD_AVG_PERIOD %d\n", HALFLIFE);
+       printf("#define LOAD_AVG_PERIOD %d\n", halflife);
        printf("#define LOAD_AVG_MAX %ld\n", max);
-//     printf("#define LOAD_AVG_MAX_N %d\n\n", n);
+       printf("#define LOAD_AVG_MAX_N %d\n\n", n);
 }
 
-void calc_accumulated_sum_32(void)
+void calc_accumulated_sum_32(const int halflife)
 {
        int i, x = sum;
 
        printf("static const u32 __accumulated_sum_N32[] = {\n\t     0,");
-       for (i = 1; i <= n/HALFLIFE+1; i++) {
+       for (i = 1; i <= n/halflife+1; i++) {
                if (i > 1)
                        x = x/2 + sum;
 
@@ -97,12 +97,23 @@ void calc_accumulated_sum_32(void)
 
 void main(void)
 {
+       int hl_value[] = HALFLIFE;
+       int hl_count = sizeof(hl_value) / sizeof(int);
+       int hl_idx, halflife;
+
        printf("/* Generated by Documentation/scheduler/sched-pelt; do not modify. */\n\n");
 
-       y = pow(0.5, 1/(double)HALFLIFE);
+       for (hl_idx = 0; hl_idx < hl_count; ++hl_idx) {
+               halflife = hl_value[hl_idx];
+
+               y = pow(0.5, 1/(double)halflife);
 
-       calc_runnable_avg_yN_inv();
-//     calc_runnable_avg_yN_sum();
-       calc_converged_max();
-//     calc_accumulated_sum_32();
+               printf("#if CONFIG_PELT_UTIL_HALFLIFE_%d\n", halflife);
+               calc_runnable_avg_yN_inv(halflife);
+               calc_runnable_avg_yN_sum(halflife);
+               calc_converged_max(halflife);
+               calc_accumulated_sum_32(halflife);
+               printf("#endif\n\n");
+       }
 }
+
index 202fd7f359b45840e3fe46f1a7735faf913b1285..d7c975cfbef929604a6b08c48bbaa9f00637541b 100644 (file)
@@ -595,6 +595,33 @@ config HAVE_UNSTABLE_SCHED_CLOCK
 config GENERIC_SCHED_CLOCK
        bool
 
+menu "FAIR Scheuler tunables"
+
+choice
+       prompt "Utilization's PELT half-Life"
+       default PELT_UTIL_HALFLIFE_16
+       help
+         Allows choosing one of the possible values for the PELT half-life to
+         be used for the update of the utilization of tasks and CPUs.
+         The half-life is the amount of [ms] required by the PELT signal to
+         build up to 50% utilization. The higher the half-life the longer it
+         takes for a task to be represented as a big one.
+
+         If not sure, use the deafult of 16 ms.
+
+config PELT_UTIL_HALFLIFE_32
+       bool "32 ms, for server"
+
+config PELT_UTIL_HALFLIFE_16
+       bool "16 ms, suggested for interactive workloads"
+
+config PELT_UTIL_HALFLIFE_8
+       bool "8 ms, very fast"
+
+endchoice
+
+endmenu # FAIR Scheduler tunables"
+
 #
 # For architectures that want to enable the support for NUMA-affine scheduler
 # balancing logic:
index a26473674fb797411b7c3b1e8790c64dcfd7ed51..3982c027b6910dfc986b370059f8aa1316f568a1 100644 (file)
@@ -1,14 +1,92 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by Documentation/scheduler/sched-pelt; do not modify. */
 
+#ifdef CONFIG_PELT_UTIL_HALFLIFE_32
 static const u32 runnable_avg_yN_inv[] = {
-       0xffffffff, 0xfa83b2da, 0xf5257d14, 0xefe4b99a, 0xeac0c6e6, 0xe5b906e6,
-       0xe0ccdeeb, 0xdbfbb796, 0xd744fcc9, 0xd2a81d91, 0xce248c14, 0xc9b9bd85,
-       0xc5672a10, 0xc12c4cc9, 0xbd08a39e, 0xb8fbaf46, 0xb504f333, 0xb123f581,
-       0xad583ee9, 0xa9a15ab4, 0xa5fed6a9, 0xa2704302, 0x9ef5325f, 0x9b8d39b9,
-       0x9837f050, 0x94f4efa8, 0x91c3d373, 0x8ea4398a, 0x8b95c1e3, 0x88980e80,
-       0x85aac367, 0x82cd8698,
+       0xffffffff,0xfa83b2da,0xf5257d14,0xefe4b99a,
+       0xeac0c6e6,0xe5b906e6,0xe0ccdeeb,0xdbfbb796,
+       0xd744fcc9,0xd2a81d91,0xce248c14,0xc9b9bd85,
+       0xc5672a10,0xc12c4cc9,0xbd08a39e,0xb8fbaf46,
+       0xb504f333,0xb123f581,0xad583ee9,0xa9a15ab4,
+       0xa5fed6a9,0xa2704302,0x9ef5325f,0x9b8d39b9,
+       0x9837f050,0x94f4efa8,0x91c3d373,0x8ea4398a,
+       0x8b95c1e3,0x88980e80,0x85aac367,0x82cd8698,
+};
+
+static const u32 runnable_avg_yN_sum[] = {
+           0, 1002, 1982, 2941, 3880, 4798, 5697, 6576, 7437, 8279, 9103,
+        9909,10698,11470,12226,12966,13690,14398,15091,15769,16433,17082,
+       17718,18340,18949,19545,20128,20698,21256,21802,22336,22859,23371,
 };
 
 #define LOAD_AVG_PERIOD 32
 #define LOAD_AVG_MAX 47742
+#define LOAD_AVG_MAX_N 345
+
+static const u32 __accumulated_sum_N32[] = {
+            0, 23371, 35056, 40899, 43820, 45281,
+        46011, 46376, 46559, 46650, 46696, 46719,
+};
+
+#endif
+
+#ifdef CONFIG_PELT_UTIL_HALFLIFE_16
+static const u32 runnable_avg_yN_inv[] = {
+       0xffffffff,0xf5257d14,0xeac0c6e6,0xe0ccdeeb,
+       0xd744fcc9,0xce248c14,0xc5672a10,0xbd08a39e,
+       0xb504f333,0xad583ee9,0xa5fed6a9,0x9ef5325f,
+       0x9837f050,0x91c3d373,0x8b95c1e3,0x85aac367,
+};
+
+static const u32 runnable_avg_yN_sum[] = {
+           0,22380,22411,22441,22470,22497,22523,22548,22572,22595,22617,
+       22638,22658,22677,22696,22714,22731,
+};
+
+#define LOAD_AVG_PERIOD 16
+#define LOAD_AVG_MAX 24152
+#define LOAD_AVG_MAX_N 517
+
+static const u32 __accumulated_sum_N32[] = {
+            0, 22731, 34096, 39779, 42620, 44041,
+        44751, 45106, 45284, 45373, 45417, 45439,
+        45450, 45456, 45459, 45460, 45461, 45461,
+        45461, 45461, 45461, 45461, 45461, 45461,
+        45461, 45461, 45461, 45461, 45461, 45461,
+        45461, 45461, 45461, 45461,
+};
+
+#endif
+
+#ifdef CONFIG_PELT_UTIL_HALFLIFE_8
+static const u32 runnable_avg_yN_inv[] = {
+       0xffffffff,0xeac0c6e6,0xd744fcc9,0xc5672a10,
+       0xb504f333,0xa5fed6a9,0x9837f050,0x8b95c1e3,
+};
+
+static const u32 runnable_avg_yN_sum[] = {
+           0,20844,20053,19327,18661,18051,17491,16978,16507,
+};
+
+#define LOAD_AVG_PERIOD 8
+#define LOAD_AVG_MAX 12337
+#define LOAD_AVG_MAX_N 603
+
+static const u32 __accumulated_sum_N32[] = {
+            0, 16507, 24760, 28887, 30950, 31982,
+        32498, 32756, 32885, 32949, 32981, 32997,
+        33005, 33009, 33011, 33012, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013, 33013,
+        33013, 33013, 33013, 33013, 33013,
+};
+
+#endif
+