linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/3] mm: An enhancement of OVERCOMMIT_GUESS
@ 2006-04-05 23:48 Hideo AOKI
  0 siblings, 0 replies; only message in thread
From: Hideo AOKI @ 2006-04-05 23:48 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

This patch is the main part of this enhancement.
Additionally, the patch includes better error handling in __vm_enough_memory().

---
Hideo Aoki, Hitachi Computer Products (America) Inc.

[-- Attachment #2: mm-consider_rsvpgs.patch --]
[-- Type: text/x-patch, Size: 1380 bytes --]

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>
---

 mmap.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff -purN linux-2.6.17-rc1-mm1/mm/mmap.c linux-2.6.17-rc1-mm1-idea6/mm/mmap.c
--- linux-2.6.17-rc1-mm1/mm/mmap.c	2006-04-04 10:43:57.000000000 -0400
+++ linux-2.6.17-rc1-mm1-idea6/mm/mmap.c	2006-04-04 14:56:51.000000000 -0400
@@ -121,14 +121,26 @@ int __vm_enough_memory(long pages, int c
 		 * 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 - hugetlb_total_pages())
@@ -150,7 +162,7 @@ int __vm_enough_memory(long pages, int c
 	 */
 	if (atomic_read(&vm_committed_space) < (long)allowed)
 		return 0;
-
+error:
 	vm_unacct_memory(pages);
 
 	return -ENOMEM;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-05 23:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-05 23:48 [patch 2/3] mm: An enhancement of OVERCOMMIT_GUESS Hideo AOKI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox