Skip to content

Commit

Permalink
[PATCH] overcommit: use totalreserve_pages for nommu
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hideo AOKI authored and Linus Torvalds committed Apr 11, 2006
1 parent 6d9f783 commit d5ddc79
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,14 +1147,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;
else
n -= totalreserve_pages;

/*
* Leave the last 3% for root
*/
if (!cap_sys_admin)
n -= n / 32;
free += n;

if (free > pages)
return 0;
vm_unacct_memory(pages);
return -ENOMEM;

goto error;
}

allowed = totalram_pages * sysctl_overcommit_ratio / 100;
Expand All @@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
*/
if (atomic_read(&vm_committed_space) < (long)allowed)
return 0;

error:
vm_unacct_memory(pages);

return -ENOMEM;
Expand Down

0 comments on commit d5ddc79

Please sign in to comment.