http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / Documentation / vm / overcommit-accounting
1 The Linux kernel supports three overcommit handling modes
2
3 0       -       Heuristic overcommit handling. Obvious overcommits of
4                 address space are refused. Used for a typical system. It
5                 ensures a seriously wild allocation fails while allowing
6                 overcommit to reduce swap usage.  root is allowed to 
7                 allocate slighly more memory in this mode. This is the 
8                 default.
9
10 1       -       No overcommit handling. Appropriate for some scientific
11                 applications.
12
13 2       -       (NEW) strict overcommit. The total address space commit
14                 for the system is not permitted to exceed swap + a
15                 configurable percentage (default is 50) of physical RAM.
16                 Depending on the percentage you use, in most situations
17                 this means a process will not be killed while accessing
18                 pages but will receive errors on memory allocation as
19                 appropriate.
20
21 The overcommit policy is set via the sysctl `vm.overcommit_memory'.
22
23 The overcommit percentage is set via `vm.overcommit_ratio'.
24
25 Gotchas
26 -------
27
28 The C language stack growth does an implicit mremap. If you want absolute
29 guarantees and run close to the edge you MUST mmap your stack for the 
30 largest size you think you will need. For typical stack usage is does
31 not matter much but it's a corner case if you really really care
32
33 In mode 2 the MAP_NORESERVE flag is ignored. 
34
35
36 How It Works
37 ------------
38
39 The overcommit is based on the following rules
40
41 For a file backed map
42         SHARED or READ-only     -       0 cost (the file is the map not swap)
43         PRIVATE WRITABLE        -       size of mapping per instance
44
45 For an anonymous or /dev/zero map
46         SHARED                  -       size of mapping
47         PRIVATE READ-only       -       0 cost (but of little use)
48         PRIVATE WRITABLE        -       size of mapping per instance
49
50 Additional accounting
51         Pages made writable copies by mmap
52         shmfs memory drawn from the same pool
53
54 Status
55 ------
56
57 o       We account mmap memory mappings
58 o       We account mprotect changes in commit
59 o       We account mremap changes in size
60 o       We account brk
61 o       We account munmap
62 o       We report the commit status in /proc
63 o       Account and check on fork
64 o       Review stack handling/building on exec
65 o       SHMfs accounting
66 o       Implement actual limit enforcement
67
68 To Do
69 -----
70 o       Account ptrace pages (this is hard)