docs: Remove spurious tag from admin-guide/mm/overcommit-accounting.rst
[linux-2.6-microblaze.git] / Documentation / vm / overcommit-accounting.rst
1 =====================
2 Overcommit Accounting
3 =====================
4
5 The Linux kernel supports the following overcommit handling modes
6
7 0
8         Heuristic overcommit handling. Obvious overcommits of address
9         space are refused. Used for a typical system. It ensures a
10         seriously wild allocation fails while allowing overcommit to
11         reduce swap usage.  root is allowed to allocate slightly more
12         memory in this mode. This is the default.
13
14 1
15         Always overcommit. Appropriate for some scientific
16         applications. Classic example is code using sparse arrays and
17         just relying on the virtual memory consisting almost entirely
18         of zero pages.
19
20 2
21         Don't overcommit. The total address space commit for the
22         system is not permitted to exceed swap + a configurable amount
23         (default is 50%) of physical RAM.  Depending on the amount you
24         use, in most situations this means a process will not be
25         killed while accessing pages but will receive errors on memory
26         allocation as appropriate.
27
28         Useful for applications that want to guarantee their memory
29         allocations will be available in the future without having to
30         initialize every page.
31
32 The overcommit policy is set via the sysctl ``vm.overcommit_memory``.
33
34 The overcommit amount can be set via ``vm.overcommit_ratio`` (percentage)
35 or ``vm.overcommit_kbytes`` (absolute value). These only have an effect
36 when ``vm.overcommit_memory`` is set to 2.
37
38 The current overcommit limit and amount committed are viewable in
39 ``/proc/meminfo`` as CommitLimit and Committed_AS respectively.
40
41 Gotchas
42 =======
43
44 The C language stack growth does an implicit mremap. If you want absolute
45 guarantees and run close to the edge you MUST mmap your stack for the
46 largest size you think you will need. For typical stack usage this does
47 not matter much but it's a corner case if you really really care
48
49 In mode 2 the MAP_NORESERVE flag is ignored.
50
51
52 How It Works
53 ============
54
55 The overcommit is based on the following rules
56
57 For a file backed map
58         | SHARED or READ-only   -       0 cost (the file is the map not swap)
59         | PRIVATE WRITABLE      -       size of mapping per instance
60
61 For an anonymous or ``/dev/zero`` map
62         | SHARED                        -       size of mapping
63         | PRIVATE READ-only     -       0 cost (but of little use)
64         | PRIVATE WRITABLE      -       size of mapping per instance
65
66 Additional accounting
67         | Pages made writable copies by mmap
68         | shmfs memory drawn from the same pool
69
70 Status
71 ======
72
73 *       We account mmap memory mappings
74 *       We account mprotect changes in commit
75 *       We account mremap changes in size
76 *       We account brk
77 *       We account munmap
78 *       We report the commit status in /proc
79 *       Account and check on fork
80 *       Review stack handling/building on exec
81 *       SHMfs accounting
82 *       Implement actual limit enforcement
83
84 To Do
85 =====
86 *       Account ptrace pages (this is hard)