diff options
| author | Andrew Morton <akpm@digeo.com> | 2003-05-25 01:12:57 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-05-25 01:12:57 -0700 |
| commit | cf50f395deee7c2c9f08d1765ec9c99f4d884ad6 (patch) | |
| tree | 2f0a372fdb31298654f8ba73b9e68036573184b0 | |
| parent | 4a3fbc84058597093f1e08ce749aa364cbf32096 (diff) | |
[PATCH] overcommit root margin
From: Dave Hansen <haveblue@us.ibm.com>
This patch makes vm_enough_memory(), more likely return failure when
overcommit_memory==0 and !CAP_SYS_ADMIN. I'm not sure it's worth having
another tunable just for this.
I also reworked the documentation a bit. It should be a lot clearer to
read now.
| -rw-r--r-- | Documentation/sysctl/vm.txt | 15 | ||||
| -rw-r--r-- | Documentation/vm/overcommit-accounting | 4 | ||||
| -rw-r--r-- | mm/mmap.c | 6 |
3 files changed, 18 insertions, 7 deletions
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt index e6f8c613c879..df64c2899046 100644 --- a/Documentation/sysctl/vm.txt +++ b/Documentation/sysctl/vm.txt @@ -35,17 +35,20 @@ See Documentation/filesystems/proc.txt overcommit_memory: This value contains a flag that enables memory overcommitment. -When this flag is 0, the kernel checks before each malloc() -to see if there's enough memory left. If the flag is nonzero, -the system pretends there's always enough memory. + +When this flag is 0, the kernel attempts to estimate the amount +of free memory left when userspace requests more memory. + +When this flag is 1, the kernel pretends there is always enough +memory until it actually runs out. + +When this flag is 2, the kernel uses a "strict overcommit" +policy that attempts to prevent any overcommit of memory. This feature can be very useful because there are a lot of programs that malloc() huge amounts of memory "just-in-case" and don't use much of it. -A value of 2 introduces a new "strict overcommit" policy -that attempts to prevent any overcommit of memory. - The default value is 0. See Documentation/vm/overcommit-accounting and diff --git a/Documentation/vm/overcommit-accounting b/Documentation/vm/overcommit-accounting index b39221feaceb..e0fd0b8f037a 100644 --- a/Documentation/vm/overcommit-accounting +++ b/Documentation/vm/overcommit-accounting @@ -3,7 +3,9 @@ The Linux kernel supports three overcommit handling modes 0 - Heuristic overcommit handling. Obvious overcommits of address space are refused. Used for a typical system. It ensures a seriously wild allocation fails while allowing - overcommit to reduce swap usage. This is the default. + overcommit to reduce swap usage. root is allowed to + allocate slighly more memory in this mode. This is the + default. 1 - No overcommit handling. Appropriate for some scientific applications. diff --git a/mm/mmap.c b/mm/mmap.c index 04e76bab2119..de7b48c49143 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -90,6 +90,12 @@ int vm_enough_memory(long pages) */ free += atomic_read(&slab_reclaim_pages); + /* + * Leave the last 3% for root + */ + if (!capable(CAP_SYS_ADMIN)) + free -= free / 32; + if (free > pages) return 1; vm_unacct_memory(pages); |
