blob: c392e28ce0ac79db6d23c4bde5d5d7433c7e0e78 [file] [log] [blame]
Ingo Molnarbadaff82017-02-08 08:45:17 +01001#ifndef _LINUX_SCHED_LOADAVG_H
2#define _LINUX_SCHED_LOADAVG_H
3
4#include <linux/sched.h>
5
Ingo Molnar06455d72017-02-01 18:25:37 +01006/*
7 * These are the constant used to fake the fixed-point load-average
8 * counting. Some notes:
9 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
10 * a load-average precision of 10 bits integer + 11 bits fractional
11 * - if you want to count load-averages more often, you need more
12 * precision, or rounding will get you. With 2-second counting freq,
13 * the EXP_n values would be 1981, 2034 and 2043 if still using only
14 * 11 bit fractions.
15 */
16extern unsigned long avenrun[]; /* Load averages */
17extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
18
19#define FSHIFT 11 /* nr of bits of precision */
20#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
21#define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */
22#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
23#define EXP_5 2014 /* 1/exp(5sec/5min) */
24#define EXP_15 2037 /* 1/exp(5sec/15min) */
25
26#define CALC_LOAD(load,exp,n) \
27 load *= exp; \
28 load += n*(FIXED_1-exp); \
29 load >>= FSHIFT;
30
31extern void calc_global_load(unsigned long ticks);
32
Ingo Molnarbadaff82017-02-08 08:45:17 +010033#endif /* _LINUX_SCHED_LOADAVG_H */