0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <math.h>
0011 #include <stdio.h>
0012
0013 #define HALFLIFE 32
0014 #define SHIFT 32
0015
0016 double y;
0017
0018 void calc_runnable_avg_yN_inv(void)
0019 {
0020 int i;
0021 unsigned int x;
0022
0023
0024 printf("static const u32 runnable_avg_yN_inv[] __maybe_unused = {");
0025 for (i = 0; i < HALFLIFE; i++) {
0026 x = ((1UL<<32)-1)*pow(y, i);
0027
0028 if (i % 6 == 0) printf("\n\t");
0029 printf("0x%8x, ", x);
0030 }
0031 printf("\n};\n\n");
0032 }
0033
0034 int sum = 1024;
0035
0036 void calc_runnable_avg_yN_sum(void)
0037 {
0038 int i;
0039
0040 printf("static const u32 runnable_avg_yN_sum[] = {\n\t 0,");
0041 for (i = 1; i <= HALFLIFE; i++) {
0042 if (i == 1)
0043 sum *= y;
0044 else
0045 sum = sum*y + 1024*y;
0046
0047 if (i % 11 == 0)
0048 printf("\n\t");
0049
0050 printf("%5d,", sum);
0051 }
0052 printf("\n};\n\n");
0053 }
0054
0055 int n = -1;
0056
0057 long max = 1024;
0058
0059 void calc_converged_max(void)
0060 {
0061 long last = 0, y_inv = ((1UL<<32)-1)*y;
0062
0063 for (; ; n++) {
0064 if (n > -1)
0065 max = ((max*y_inv)>>SHIFT) + 1024;
0066
0067
0068
0069
0070
0071 if (last == max)
0072 break;
0073
0074 last = max;
0075 }
0076 n--;
0077 printf("#define LOAD_AVG_PERIOD %d\n", HALFLIFE);
0078 printf("#define LOAD_AVG_MAX %ld\n", max);
0079
0080 }
0081
0082 void calc_accumulated_sum_32(void)
0083 {
0084 int i, x = sum;
0085
0086 printf("static const u32 __accumulated_sum_N32[] = {\n\t 0,");
0087 for (i = 1; i <= n/HALFLIFE+1; i++) {
0088 if (i > 1)
0089 x = x/2 + sum;
0090
0091 if (i % 6 == 0)
0092 printf("\n\t");
0093
0094 printf("%6d,", x);
0095 }
0096 printf("\n};\n\n");
0097 }
0098
0099 void main(void)
0100 {
0101 printf("/* Generated by Documentation/scheduler/sched-pelt; do not modify. */\n\n");
0102
0103 y = pow(0.5, 1/(double)HALFLIFE);
0104
0105 calc_runnable_avg_yN_inv();
0106
0107 calc_converged_max();
0108
0109 }