aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/vm/overcommit-accounting
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/vm/overcommit-accounting
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'Documentation/vm/overcommit-accounting')
-rw-r--r--Documentation/vm/overcommit-accounting73
1 files changed, 73 insertions, 0 deletions
diff --git a/Documentation/vm/overcommit-accounting b/Documentation/vm/overcommit-accounting
new file mode 100644
index 000000000000..21c7b1f8f32b
--- /dev/null
+++ b/Documentation/vm/overcommit-accounting
@@ -0,0 +1,73 @@
1The Linux kernel supports the following overcommit handling modes
2
30 - 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
101 - Always overcommit. Appropriate for some scientific
11 applications.
12
132 - Don't 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
21The overcommit policy is set via the sysctl `vm.overcommit_memory'.
22
23The overcommit percentage is set via `vm.overcommit_ratio'.
24
25The current overcommit limit and amount committed are viewable in
26/proc/meminfo as CommitLimit and Committed_AS respectively.
27
28Gotchas
29-------
30
31The C language stack growth does an implicit mremap. If you want absolute
32guarantees and run close to the edge you MUST mmap your stack for the
33largest size you think you will need. For typical stack usage this does
34not matter much but it's a corner case if you really really care
35
36In mode 2 the MAP_NORESERVE flag is ignored.
37
38
39How It Works
40------------
41
42The overcommit is based on the following rules
43
44For a file backed map
45 SHARED or READ-only - 0 cost (the file is the map not swap)
46 PRIVATE WRITABLE - size of mapping per instance
47
48For an anonymous or /dev/zero map
49 SHARED - size of mapping
50 PRIVATE READ-only - 0 cost (but of little use)
51 PRIVATE WRITABLE - size of mapping per instance
52
53Additional accounting
54 Pages made writable copies by mmap
55 shmfs memory drawn from the same pool
56
57Status
58------
59
60o We account mmap memory mappings
61o We account mprotect changes in commit
62o We account mremap changes in size
63o We account brk
64o We account munmap
65o We report the commit status in /proc
66o Account and check on fork
67o Review stack handling/building on exec
68o SHMfs accounting
69o Implement actual limit enforcement
70
71To Do
72-----
73o Account ptrace pages (this is hard)