提交 d5ddc79b 编写于 作者: H Hideo AOKI 提交者: Linus Torvalds

[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: NHideo Aoki <haoki@redhat.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 6d9f7839
...@@ -1147,14 +1147,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin) ...@@ -1147,14 +1147,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
* only call if we're about to fail. * only call if we're about to fail.
*/ */
n = nr_free_pages(); n = nr_free_pages();
/*
* Leave reserved pages. The pages are not for anonymous pages.
*/
if (n <= totalreserve_pages)
goto error;
else
n -= totalreserve_pages;
/*
* Leave the last 3% for root
*/
if (!cap_sys_admin) if (!cap_sys_admin)
n -= n / 32; n -= n / 32;
free += n; free += n;
if (free > pages) if (free > pages)
return 0; return 0;
vm_unacct_memory(pages);
return -ENOMEM; goto error;
} }
allowed = totalram_pages * sysctl_overcommit_ratio / 100; allowed = totalram_pages * sysctl_overcommit_ratio / 100;
...@@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin) ...@@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
*/ */
if (atomic_read(&vm_committed_space) < (long)allowed) if (atomic_read(&vm_committed_space) < (long)allowed)
return 0; return 0;
error:
vm_unacct_memory(pages); vm_unacct_memory(pages);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册