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