Commit 6d9f7839 authored by Hideo AOKI's avatar Hideo AOKI Committed by Linus Torvalds
Browse files

[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
Signed-off-by: default avatarHideo Aoki <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent cb45b0e9
......@@ -121,14 +121,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
* only call if we're about to fail.
n = nr_free_pages();
* Leave reserved pages. The pages are not for anonymous pages.
if (n <= totalreserve_pages)
goto error;
n -= totalreserve_pages;
* Leave the last 3% for root
if (!cap_sys_admin)
n -= n / 32;
free += n;
if (free > pages)
return 0;
return -ENOMEM;
goto error;
allowed = (totalram_pages - hugetlb_total_pages())
......@@ -150,7 +162,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
if (atomic_read(&vm_committed_space) < (long)allowed)
return 0;
return -ENOMEM;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment