diff options
author | Hideo AOKI <haoki@redhat.com> | 2006-04-11 01:53:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-11 09:18:32 -0400 |
commit | d5ddc79bcaab6975e7671805c3578407dc33b764 (patch) | |
tree | de29b6d1c43fa6f5a1aca52ad6c2cc6027edc1fc /mm | |
parent | 6d9f78396583244258080f3369889644c06c37c8 (diff) |
[PATCH] overcommit: use totalreserve_pages for nommu
This patch is an enhancement of OVERCOMMIT_GUESS algorithm in
__vm_enough_memory() in mm/nommu.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/nommu.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index db45efac17cc..029fadac0fb5 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1147,14 +1147,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin) | |||
1147 | * only call if we're about to fail. | 1147 | * only call if we're about to fail. |
1148 | */ | 1148 | */ |
1149 | n = nr_free_pages(); | 1149 | n = nr_free_pages(); |
1150 | |||
1151 | /* | ||
1152 | * Leave reserved pages. The pages are not for anonymous pages. | ||
1153 | */ | ||
1154 | if (n <= totalreserve_pages) | ||
1155 | goto error; | ||
1156 | else | ||
1157 | n -= totalreserve_pages; | ||
1158 | |||
1159 | /* | ||
1160 | * Leave the last 3% for root | ||
1161 | */ | ||
1150 | if (!cap_sys_admin) | 1162 | if (!cap_sys_admin) |
1151 | n -= n / 32; | 1163 | n -= n / 32; |
1152 | free += n; | 1164 | free += n; |
1153 | 1165 | ||
1154 | if (free > pages) | 1166 | if (free > pages) |
1155 | return 0; | 1167 | return 0; |
1156 | vm_unacct_memory(pages); | 1168 | |
1157 | return -ENOMEM; | 1169 | goto error; |
1158 | } | 1170 | } |
1159 | 1171 | ||
1160 | allowed = totalram_pages * sysctl_overcommit_ratio / 100; | 1172 | allowed = totalram_pages * sysctl_overcommit_ratio / 100; |
@@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin) | |||
1175 | */ | 1187 | */ |
1176 | if (atomic_read(&vm_committed_space) < (long)allowed) | 1188 | if (atomic_read(&vm_committed_space) < (long)allowed) |
1177 | return 0; | 1189 | return 0; |
1178 | 1190 | error: | |
1179 | vm_unacct_memory(pages); | 1191 | vm_unacct_memory(pages); |
1180 | 1192 | ||
1181 | return -ENOMEM; | 1193 | return -ENOMEM; |