aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-02-15 18:55:09 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-02-15 18:55:09 +0000
commit3ab98a471c4b1aec557583e674beacd15be4955d (patch)
tree69367e678dd8ce0bf0495ccdf1a1712913949390 /libgo
parent4dddfc74f331653b453b9123ecf3c93a58a9aade (diff)
downloadgcc-3ab98a471c4b1aec557583e674beacd15be4955d.zip
gcc-3ab98a471c4b1aec557583e674beacd15be4955d.tar.gz
gcc-3ab98a471c4b1aec557583e674beacd15be4955d.tar.bz2
runtime: Do not reserve huge amount of swap on 32 bit architectures.
The mmap() call which reserves the arena should have MAP_NORESERVE flag as in typical cases this memory will never be (fully) needed. This matters in environments which do not do Linux style memory overcommit, such as OpenIndiana/OpenSolaris/Solaris. The MAP_NORESERVE flag does not exist on all operating systems (for example FreeBSD). Therefore we define it to zero value in case it does not exist. Fixes issue 21. From-SVN: r196088
Diffstat (limited to 'libgo')
-rw-r--r--libgo/runtime/mem.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libgo/runtime/mem.c b/libgo/runtime/mem.c
index e70694c..e606bdd 100644
--- a/libgo/runtime/mem.c
+++ b/libgo/runtime/mem.c
@@ -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 @@ runtime_SysReserve(void *v, uintptr n)
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;