~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/scheduler/sched-pelt.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * The following program is used to generate the constants for
  3  * computing sched averages.
  4  *
  5  * ==============================================================
  6  *              C program (compile with -lm)
  7  * ==============================================================
  8  */
  9 
 10 #include <math.h>
 11 #include <stdio.h>
 12 
 13 #define HALFLIFE 32
 14 #define SHIFT 32
 15 
 16 double y;
 17 
 18 void calc_runnable_avg_yN_inv(void)
 19 {
 20         int i;
 21         unsigned int x;
 22 
 23         /* To silence -Wunused-but-set-variable warnings. */
 24         printf("static const u32 runnable_avg_yN_inv[] __maybe_unused = {");
 25         for (i = 0; i < HALFLIFE; i++) {
 26                 x = ((1UL<<32)-1)*pow(y, i);
 27 
 28                 if (i % 6 == 0) printf("\n\t");
 29                 printf("0x%8x, ", x);
 30         }
 31         printf("\n};\n\n");
 32 }
 33 
 34 int sum = 1024;
 35 
 36 void calc_runnable_avg_yN_sum(void)
 37 {
 38         int i;
 39 
 40         printf("static const u32 runnable_avg_yN_sum[] = {\n\t    0,");
 41         for (i = 1; i <= HALFLIFE; i++) {
 42                 if (i == 1)
 43                         sum *= y;
 44                 else
 45                         sum = sum*y + 1024*y;
 46 
 47                 if (i % 11 == 0)
 48                         printf("\n\t");
 49 
 50                 printf("%5d,", sum);
 51         }
 52         printf("\n};\n\n");
 53 }
 54 
 55 int n = -1;
 56 /* first period */
 57 long max = 1024;
 58 
 59 void calc_converged_max(void)
 60 {
 61         long last = 0, y_inv = ((1UL<<32)-1)*y;
 62 
 63         for (; ; n++) {
 64                 if (n > -1)
 65                         max = ((max*y_inv)>>SHIFT) + 1024;
 66                         /*
 67                          * This is the same as:
 68                          * max = max*y + 1024;
 69                          */
 70 
 71                 if (last == max)
 72                         break;
 73 
 74                 last = max;
 75         }
 76         n--;
 77         printf("#define LOAD_AVG_PERIOD %d\n", HALFLIFE);
 78         printf("#define LOAD_AVG_MAX %ld\n", max);
 79 //      printf("#define LOAD_AVG_MAX_N %d\n\n", n);
 80 }
 81 
 82 void calc_accumulated_sum_32(void)
 83 {
 84         int i, x = sum;
 85 
 86         printf("static const u32 __accumulated_sum_N32[] = {\n\t     0,");
 87         for (i = 1; i <= n/HALFLIFE+1; i++) {
 88                 if (i > 1)
 89                         x = x/2 + sum;
 90 
 91                 if (i % 6 == 0)
 92                         printf("\n\t");
 93 
 94                 printf("%6d,", x);
 95         }
 96         printf("\n};\n\n");
 97 }
 98 
 99 void main(void)
100 {
101         printf("/* Generated by Documentation/scheduler/sched-pelt; do not modify. */\n\n");
102 
103         y = pow(0.5, 1/(double)HALFLIFE);
104 
105         calc_runnable_avg_yN_inv();
106 //      calc_runnable_avg_yN_sum();
107         calc_converged_max();
108 //      calc_accumulated_sum_32();
109 }
110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php