about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/allocatestack.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 2a5ac22117..e8dfbbb8de 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -656,6 +656,15 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 
 	      return errno;
 	    }
+	  /* We've marked this guard region unwritable, but it's
+	     possible it already became resident, the most common case
+	     being transparent hugepages; if stack + guard (+ adjacent
+	     mmap regions) were more than 2MB, the kernel might have
+	     filled in a full hugepage when we touched the thread
+	     descriptor above.  This can waste a lot of memory; mark
+	     the guard unused. This shouldn't fail, but if it does,
+	     we can't really do anything about it so ignore it. */
+	  madvise (guard, guardsize, MADV_DONTNEED);
 
 	  pd->guardsize = guardsize;
 	}