Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpu-load: standardize document format

Each text file under Documentation follows a different
format. Some doesn't even have titles!

Change its representation to follow the adopted standard,
using ReST markups for it to be parseable by Sphinx:

- mark literals;
- Adjust document title;
- Use a list for references.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
09338fb0 f68ac62d

+59 -58
+59 -58
Documentation/cpu-load.txt
··· 1 + ======== 1 2 CPU load 2 - -------- 3 + ======== 3 4 4 - Linux exports various bits of information via `/proc/stat' and 5 - `/proc/uptime' that userland tools, such as top(1), use to calculate 6 - the average time system spent in a particular state, for example: 5 + Linux exports various bits of information via ``/proc/stat`` and 6 + ``/proc/uptime`` that userland tools, such as top(1), use to calculate 7 + the average time system spent in a particular state, for example:: 7 8 8 9 $ iostat 9 10 Linux 2.6.18.3-exp (linmac) 02/20/2007 ··· 18 17 system spent 10.01% of the time doing work in user space, 2.92% in the 19 18 kernel, and was overall 81.63% of the time idle. 20 19 21 - In most cases the `/proc/stat' information reflects the reality quite 20 + In most cases the ``/proc/stat`` information reflects the reality quite 22 21 closely, however due to the nature of how/when the kernel collects 23 22 this data sometimes it can not be trusted at all. 24 23 ··· 34 33 ------- 35 34 36 35 If we imagine the system with one task that periodically burns cycles 37 - in the following manner: 36 + in the following manner:: 38 37 39 - time line between two timer interrupts 40 - |--------------------------------------| 41 - ^ ^ 42 - |_ something begins working | 43 - |_ something goes to sleep 44 - (only to be awaken quite soon) 38 + time line between two timer interrupts 39 + |--------------------------------------| 40 + ^ ^ 41 + |_ something begins working | 42 + |_ something goes to sleep 43 + (only to be awaken quite soon) 45 44 46 45 In the above situation the system will be 0% loaded according to the 47 - `/proc/stat' (since the timer interrupt will always happen when the 46 + ``/proc/stat`` (since the timer interrupt will always happen when the 48 47 system is executing the idle handler), but in reality the load is 49 48 closer to 99%. 50 49 51 50 One can imagine many more situations where this behavior of the kernel 52 - will lead to quite erratic information inside `/proc/stat'. 51 + will lead to quite erratic information inside ``/proc/stat``:: 53 52 54 53 55 - /* gcc -o hog smallhog.c */ 56 - #include <time.h> 57 - #include <limits.h> 58 - #include <signal.h> 59 - #include <sys/time.h> 60 - #define HIST 10 54 + /* gcc -o hog smallhog.c */ 55 + #include <time.h> 56 + #include <limits.h> 57 + #include <signal.h> 58 + #include <sys/time.h> 59 + #define HIST 10 61 60 62 - static volatile sig_atomic_t stop; 61 + static volatile sig_atomic_t stop; 63 62 64 - static void sighandler (int signr) 65 - { 66 - (void) signr; 67 - stop = 1; 68 - } 69 - static unsigned long hog (unsigned long niters) 70 - { 71 - stop = 0; 72 - while (!stop && --niters); 73 - return niters; 74 - } 75 - int main (void) 76 - { 77 - int i; 78 - struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 1 }, 79 - .it_value = { .tv_sec = 0, .tv_usec = 1 } }; 80 - sigset_t set; 81 - unsigned long v[HIST]; 82 - double tmp = 0.0; 83 - unsigned long n; 84 - signal (SIGALRM, &sighandler); 85 - setitimer (ITIMER_REAL, &it, NULL); 63 + static void sighandler (int signr) 64 + { 65 + (void) signr; 66 + stop = 1; 67 + } 68 + static unsigned long hog (unsigned long niters) 69 + { 70 + stop = 0; 71 + while (!stop && --niters); 72 + return niters; 73 + } 74 + int main (void) 75 + { 76 + int i; 77 + struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 1 }, 78 + .it_value = { .tv_sec = 0, .tv_usec = 1 } }; 79 + sigset_t set; 80 + unsigned long v[HIST]; 81 + double tmp = 0.0; 82 + unsigned long n; 83 + signal (SIGALRM, &sighandler); 84 + setitimer (ITIMER_REAL, &it, NULL); 86 85 87 - hog (ULONG_MAX); 88 - for (i = 0; i < HIST; ++i) v[i] = ULONG_MAX - hog (ULONG_MAX); 89 - for (i = 0; i < HIST; ++i) tmp += v[i]; 90 - tmp /= HIST; 91 - n = tmp - (tmp / 3.0); 86 + hog (ULONG_MAX); 87 + for (i = 0; i < HIST; ++i) v[i] = ULONG_MAX - hog (ULONG_MAX); 88 + for (i = 0; i < HIST; ++i) tmp += v[i]; 89 + tmp /= HIST; 90 + n = tmp - (tmp / 3.0); 92 91 93 - sigemptyset (&set); 94 - sigaddset (&set, SIGALRM); 92 + sigemptyset (&set); 93 + sigaddset (&set, SIGALRM); 95 94 96 - for (;;) { 97 - hog (n); 98 - sigwait (&set, &i); 99 - } 100 - return 0; 101 - } 95 + for (;;) { 96 + hog (n); 97 + sigwait (&set, &i); 98 + } 99 + return 0; 100 + } 102 101 103 102 104 103 References 105 104 ---------- 106 105 107 - http://lkml.org/lkml/2007/2/12/6 108 - Documentation/filesystems/proc.txt (1.8) 106 + - http://lkml.org/lkml/2007/2/12/6 107 + - Documentation/filesystems/proc.txt (1.8) 109 108 110 109 111 110 Thanks