public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Use MAP_NORESERVE
@ 2013-02-15 18:55 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2013-02-15 18:55 UTC (permalink / raw)
  To: gcc-patches

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

This patch from Janne Snabb changes libgo to use MAP_NORESERVE when
allocating the large memory arena.  This makes no difference on
GNU/Linux but reportedly helps on OpenIndiana and OpenSolaris.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 805 bytes --]

diff -r 38275c614957 libgo/runtime/mem.c
--- a/libgo/runtime/mem.c	Fri Feb 15 10:48:31 2013 -0800
+++ b/libgo/runtime/mem.c	Fri Feb 15 10:49:37 2013 -0800
@@ -18,6 +18,10 @@
 #endif
 #endif
 
+#ifndef MAP_NORESERVE
+#define MAP_NORESERVE 0
+#endif
+
 #ifdef USE_DEV_ZERO
 static int dev_zero = -1;
 #endif
@@ -134,7 +138,11 @@
 		return v;
 	}
 	
-	p = runtime_mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, fd, 0);
+	// Use the MAP_NORESERVE mmap() flag here because typically most of
+	// this reservation will never be used. It does not make sense
+	// reserve a huge amount of unneeded swap space. This is important on
+	// systems which do not overcommit memory by default.
+	p = runtime_mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_NORESERVE, fd, 0);
 	if(p == MAP_FAILED)
 		return nil;
 	return p;

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

only message in thread, other threads:[~2013-02-15 18:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 18:55 libgo patch committed: Use MAP_NORESERVE Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).