About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / vm / overcommit-accounting

Custom Search

Based on kernel version 3.15.4. Page generated on 2014-07-07 09:05 EST.

1	The Linux kernel supports the following overcommit handling modes
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 slightly more memory in this mode. This is the 
8			default.
10	1	-	Always overcommit. Appropriate for some scientific
11			applications. Classic example is code using sparse arrays
12			and just relying on the virtual memory consisting almost
13			entirely of zero pages.
15	2	-	Don't overcommit. The total address space commit
16			for the system is not permitted to exceed swap + a
17			configurable amount (default is 50%) of physical RAM.
18			Depending on the amount you use, in most situations
19			this means a process will not be killed while accessing
20			pages but will receive errors on memory allocation as
21			appropriate.
23			Useful for applications that want to guarantee their
24			memory allocations will be available in the future
25			without having to initialize every page.
27	The overcommit policy is set via the sysctl `vm.overcommit_memory'.
29	The overcommit amount can be set via `vm.overcommit_ratio' (percentage)
30	or `vm.overcommit_kbytes' (absolute value).
32	The current overcommit limit and amount committed are viewable in
33	/proc/meminfo as CommitLimit and Committed_AS respectively.
35	Gotchas
36	-------
38	The C language stack growth does an implicit mremap. If you want absolute
39	guarantees and run close to the edge you MUST mmap your stack for the 
40	largest size you think you will need. For typical stack usage this does
41	not matter much but it's a corner case if you really really care
43	In mode 2 the MAP_NORESERVE flag is ignored. 
46	How It Works
47	------------
49	The overcommit is based on the following rules
51	For a file backed map
52		SHARED or READ-only	-	0 cost (the file is the map not swap)
53		PRIVATE WRITABLE	-	size of mapping per instance
55	For an anonymous or /dev/zero map
56		SHARED			-	size of mapping
57		PRIVATE READ-only	-	0 cost (but of little use)
58		PRIVATE WRITABLE	-	size of mapping per instance
60	Additional accounting
61		Pages made writable copies by mmap
62		shmfs memory drawn from the same pool
64	Status
65	------
67	o	We account mmap memory mappings
68	o	We account mprotect changes in commit
69	o	We account mremap changes in size
70	o	We account brk
71	o	We account munmap
72	o	We report the commit status in /proc
73	o	Account and check on fork
74	o	Review stack handling/building on exec
75	o	SHMfs accounting
76	o	Implement actual limit enforcement
78	To Do
79	-----
80	o	Account ptrace pages (this is hard)
Hide Line Numbers
About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.