aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorHideo AOKI <haoki@redhat.com>2006-04-11 01:53:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:32 -0400
commit6d9f78396583244258080f3369889644c06c37c8 (patch)
tree645f5e8630bc57e3a8f5653dc941fc0232b5e98b /mm
parentcb45b0e966cbe747b6189c15b108901cc7d6c97c (diff)
[PATCH] overcommit: use totalreserve_pages
This patch is an enhancement of OVERCOMMIT_GUESS algorithm in __vm_enough_memory() in mm/mmap.c. When the OVERCOMMIT_GUESS algorithm calculates the number of free pages, the algorithm subtracts the number of reserved pages from the result nr_free_pages(). Signed-off-by: Hideo Aoki <haoki@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mmap.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index eab6fcb65e11..e6ee12344b13 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -121,14 +121,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
121 * only call if we're about to fail. 121 * only call if we're about to fail.
122 */ 122 */
123 n = nr_free_pages(); 123 n = nr_free_pages();
124
125 /*
126 * Leave reserved pages. The pages are not for anonymous pages.
127 */
128 if (n <= totalreserve_pages)
129 goto error;
130 else
131 n -= totalreserve_pages;
132
133 /*
134 * Leave the last 3% for root
135 */
124 if (!cap_sys_admin) 136 if (!cap_sys_admin)
125 n -= n / 32; 137 n -= n / 32;
126 free += n; 138 free += n;
127 139
128 if (free > pages) 140 if (free > pages)
129 return 0; 141 return 0;
130 vm_unacct_memory(pages); 142
131 return -ENOMEM; 143 goto error;
132 } 144 }
133 145
134 allowed = (totalram_pages - hugetlb_total_pages()) 146 allowed = (totalram_pages - hugetlb_total_pages())
@@ -150,7 +162,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
150 */ 162 */
151 if (atomic_read(&vm_committed_space) < (long)allowed) 163 if (atomic_read(&vm_committed_space) < (long)allowed)
152 return 0; 164 return 0;
153 165error:
154 vm_unacct_memory(pages); 166 vm_unacct_memory(pages);
155 167
156 return -ENOMEM; 168 return -ENOMEM;