about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--nptl/ChangeLog9
-rw-r--r--nptl/allocatestack.c8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/Makefile3
-rw-r--r--nptl/sysdeps/x86_64/pthreaddef.h11
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c1
6 files changed, 32 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b3f893bde7..06559ea963 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-05-09  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c: New file.
+
 2003-05-08  Ulrich Drepper  <drepper@redhat.com>
 
 	* malloc/thread-m.h: Remove special handling of thread_atfork if
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 7bd8025850..f46c221c9a 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,12 @@
+2003-05-09  Ulrich Drepper  <drepper@redhat.com>
+
+	* allocatestack.c (allocate_stack): If ARCH_RETRY_MMAP is defined,
+	use it in case mmap to allocate the stack fails.
+	* sysdeps/unix/sysv/linux/x86_64/Makefile: Don't define
+	ARCH_MAP_FLAGS here.
+	* sysdeps/x86_64/pthreaddef.h: Define ARCH_MAP_FLAGS and
+	ARCH_RETRY_MMAP.
+
 2003-05-08  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/unix/sysv/linux/fork.c: Complete rewrite of the atfork
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 680f365e04..95ee992a18 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -393,7 +393,13 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 		      MAP_PRIVATE | MAP_ANONYMOUS | ARCH_MAP_FLAGS, -1, 0);
 
 	  if (__builtin_expect (mem == MAP_FAILED, 0))
-	    return errno;
+	    {
+#ifdef ARCH_RETRY_MMAP
+	      mem = ARCH_RETRY_MMAP (size);
+	      if (__builtin_expect (mem == MAP_FAILED, 0))
+#endif
+		return errno;
+	    }
 
 	  /* SIZE is guaranteed to be greater than zero.
 	     So we can never get a null pointer back from mmap.  */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile b/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile
index 9ecb7b092a..d3e5eb54d7 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile
@@ -1,6 +1,3 @@
 ifeq ($(subdir),nptl)
 CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions -fno-asynchronous-unwind-tables
-
-# We need to make sure that stack memory is allocated in the low 4GB.
-CFLAGS-pthread_create.c += -DARCH_MAP_FLAGS=MAP_32BIT
 endif
diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
index 90a67f1751..27896a445c 100644
--- a/nptl/sysdeps/x86_64/pthreaddef.h
+++ b/nptl/sysdeps/x86_64/pthreaddef.h
@@ -36,6 +36,17 @@
   ({ char *frame; asm ("movq %%rsp, %0" : "=r" (frame)); frame; })
 
 
+/* We prefer to have the stack allocated in the low 4GB since this
+   allows faster context switches.  */
+#define ARCH_MAP_FLAGS MAP_32BIT
+
+/* If it is not possible to allocate memory there retry without that
+   flag.  */
+#define ARCH_RETRY_MMAP(size) \
+  mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,			      \
+	MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)
+
+
 /* XXX Until we have a better place keep the definitions here.  */
 
 /* While there is no such syscall.  */
diff --git a/sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c b/sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c
new file mode 100644
index 0000000000..a58d40a9c1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c
@@ -0,0 +1 @@
+#include "../i386/get_clockfreq.c"