c6d234
commit 37f8abad1c7b274e66eaf2d04684bd8a7ba0bcef
c6d234
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
c6d234
Date:   Mon Jan 30 18:07:32 2017 -0200
c6d234
c6d234
    nptl: Remove COLORING_INCREMENT
c6d234
    
c6d234
    This patch removes the COLORING_INCREMENT define and usage on allocatestack.c.
c6d234
    It has not been used since 564cd8b67ec487f (glibc-2.3.3) by any architecture.
c6d234
    The idea is to simplify the code by removing obsolete code.
c6d234
    
c6d234
            * nptl/allocatestack.c [COLORING_INCREMENT] (nptl_ncreated): Remove.
c6d234
            (allocate_stack): Remove COLORING_INCREMENT usage.
c6d234
            * nptl/stack-aliasing.h (COLORING_INCREMENT). Likewise.
c6d234
            * sysdeps/i386/i686/stack-aliasing.h (COLORING_INCREMENT): Likewise.
c6d234
c6d234
Conflicts:
c6d234
	nptl/allocatestack.c
c6d234
c6d234
Textual conflict due to missing backport of commit
c6d234
a1ffb40e32741f992c743e7b16c061fefa3747ac (Use glibc_likely instead
c6d234
__builtin_expect.).
c6d234
c6d234
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
c6d234
index 0fba6ce3474e8b35..00f9dcffe721a6b3 100644
c6d234
--- a/nptl/allocatestack.c
c6d234
+++ b/nptl/allocatestack.c
c6d234
@@ -124,11 +124,6 @@ static uintptr_t in_flight_stack;
c6d234
 list_t __stack_user __attribute__ ((nocommon));
c6d234
 hidden_data_def (__stack_user)
c6d234
 
c6d234
-#if COLORING_INCREMENT != 0
c6d234
-/* Number of threads created.  */
c6d234
-static unsigned int nptl_ncreated;
c6d234
-#endif
c6d234
-
c6d234
 
c6d234
 /* Check whether the stack is still used or not.  */
c6d234
 #define FREE_P(descr) ((descr)->tid <= 0)
c6d234
@@ -456,14 +451,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
c6d234
       const int prot = (PROT_READ | PROT_WRITE
c6d234
 			| ((GL(dl_stack_flags) & PF_X) ? PROT_EXEC : 0));
c6d234
 
c6d234
-#if COLORING_INCREMENT != 0
c6d234
-      /* Add one more page for stack coloring.  Don't do it for stacks
c6d234
-	 with 16 times pagesize or larger.  This might just cause
c6d234
-	 unnecessary misalignment.  */
c6d234
-      if (size <= 16 * pagesize_m1)
c6d234
-	size += pagesize_m1 + 1;
c6d234
-#endif
c6d234
-
c6d234
       /* Adjust the stack size for alignment.  */
c6d234
       size &= ~__static_tls_align_m1;
c6d234
       assert (size != 0);
c6d234
@@ -506,34 +493,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
c6d234
 	     So we can never get a null pointer back from mmap.  */
c6d234
 	  assert (mem != NULL);
c6d234
 
c6d234
-#if COLORING_INCREMENT != 0
c6d234
-	  /* Atomically increment NCREATED.  */
c6d234
-	  unsigned int ncreated = atomic_increment_val (&nptl_ncreated);
c6d234
-
c6d234
-	  /* We chose the offset for coloring by incrementing it for
c6d234
-	     every new thread by a fixed amount.  The offset used
c6d234
-	     module the page size.  Even if coloring would be better
c6d234
-	     relative to higher alignment values it makes no sense to
c6d234
-	     do it since the mmap() interface does not allow us to
c6d234
-	     specify any alignment for the returned memory block.  */
c6d234
-	  size_t coloring = (ncreated * COLORING_INCREMENT) & pagesize_m1;
c6d234
-
c6d234
-	  /* Make sure the coloring offsets does not disturb the alignment
c6d234
-	     of the TCB and static TLS block.  */
c6d234
-	  if (__builtin_expect ((coloring & __static_tls_align_m1) != 0, 0))
c6d234
-	    coloring = (((coloring + __static_tls_align_m1)
c6d234
-			 & ~(__static_tls_align_m1))
c6d234
-			& ~pagesize_m1);
c6d234
-#else
c6d234
-	  /* Unless specified we do not make any adjustments.  */
c6d234
-# define coloring 0
c6d234
-#endif
c6d234
-
c6d234
 	  /* Place the thread descriptor at the end of the stack.  */
c6d234
 #if TLS_TCB_AT_TP
c6d234
-	  pd = (struct pthread *) ((char *) mem + size - coloring) - 1;
c6d234
+	  pd = (struct pthread *) ((char *) mem + size) - 1;
c6d234
 #elif TLS_DTV_AT_TP
c6d234
-	  pd = (struct pthread *) ((((uintptr_t) mem + size - coloring
c6d234
+	  pd = (struct pthread *) ((((uintptr_t) mem + size
c6d234
 				    - __static_tls_size)
c6d234
 				    & ~__static_tls_align_m1)
c6d234
 				   - TLS_PRE_TCB_SIZE);
c6d234
diff --git a/nptl/stack-aliasing.h b/nptl/stack-aliasing.h
c6d234
index 526b54e18f7e0a27..62fdc9265e0038e6 100644
c6d234
--- a/nptl/stack-aliasing.h
c6d234
+++ b/nptl/stack-aliasing.h
c6d234
@@ -16,12 +16,6 @@
c6d234
    License along with the GNU C Library; if not, see
c6d234
    <http://www.gnu.org/licenses/>.  */
c6d234
 
c6d234
-/* This is a number of bytes (less than a page) by which to "color" the
c6d234
-   starting stack address of new threads.  This number is multiplied by the
c6d234
-   number of threads created so far and then truncated modulo page size,
c6d234
-   to get a roughly even distribution of values for different threads.  */
c6d234
-#define COLORING_INCREMENT      0
c6d234
-
c6d234
 /* This is a number of bytes that is an alignment that should be avoided
c6d234
    when choosing the exact size of a new thread's stack.  If the size
c6d234
    chosen is aligned to this, an extra page will be added to render the
c6d234
diff --git a/sysdeps/i386/i686/stack-aliasing.h b/sysdeps/i386/i686/stack-aliasing.h
c6d234
index 1e35ceb2061d60f9..d73e45461f928a6a 100644
c6d234
--- a/sysdeps/i386/i686/stack-aliasing.h
c6d234
+++ b/sysdeps/i386/i686/stack-aliasing.h
c6d234
@@ -16,11 +16,6 @@
c6d234
    License along with the GNU C Library; if not, see
c6d234
    <http://www.gnu.org/licenses/>.  */
c6d234
 
c6d234
-/* It turns out that stack coloring is in general not good on P4s.  Some
c6d234
-   applications will benefit.  We will probably have a configuration option
c6d234
-   at some point.  To enable coloring, set this to 128.  */
c6d234
-#define COLORING_INCREMENT      0
c6d234
-
c6d234
 /* What is useful is to avoid the 64k aliasing problem which reliably
c6d234
    happens if all stacks use sizes which are a multiple of 64k.  Tell
c6d234
    the stack allocator to disturb this by allocation one more page if