This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch siddhesh/pthread_attr_default updated. glibc-2.17-395-gd27657e


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, siddhesh/pthread_attr_default has been updated
       via  d27657e0499ac23e9266a53da2f52db0d8c279ed (commit)
      from  b3a243b7255a1b65a5ab48ba3c22714616d1f4ff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d27657e0499ac23e9266a53da2f52db0d8c279ed

commit d27657e0499ac23e9266a53da2f52db0d8c279ed
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Thu Mar 14 16:58:50 2013 +0530

    Correct the test case
    
    I had incorrectly assumed that the guardsize was being adjusted
    against the page size.  What's actually happening is that
    allocate_stack perturbs the stack size by a page if it is a multiple
    of 64k to avoid aliasing conflicts that cause a performance drop on P4
    and later.  So now I perturb the stacksize request by a page in
    advance, so that pthread_create does not modify the requested size.

diff --git a/nptl/tst-default-attr.c b/nptl/tst-default-attr.c
index b02d812..867e91e 100644
--- a/nptl/tst-default-attr.c
+++ b/nptl/tst-default-attr.c
@@ -21,11 +21,13 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>
+#include <unistd.h>
+#include <errno.h>
 
 static size_t stacksize = 1024 * 1024;
 
 void *
-verify_result (pthread_attr_t *attr, int adjust_guard)
+verify_result (pthread_attr_t *attr)
 {
   int ret;
   size_t stack;
@@ -36,24 +38,10 @@ verify_result (pthread_attr_t *attr, int adjust_guard)
       return (void *) (uintptr_t) 1;
     }
 
-  /* FIXME Currently, glibc pthread stack size includes the guard size.  This
-     needs to be fixed eventually, but until then, adjust the stack size so
-     that this test does not fail.  */
-  if (adjust_guard)
-    {
-      size_t guard;
-      if ((ret = pthread_attr_getguardsize (attr, &guard)) != 0)
-	{
-	  printf ("pthread_attr_getguardsize failed: %s\n", strerror (ret));
-	  return (void *) (uintptr_t) 1;
-	}
-      stack -= guard;
-    }
-
   if (stacksize != stack)
     {
-      puts ("pthread_attr_set_default did not work for stacksize");
-      printf ("%zd, %zd\n", stacksize, stack);
+      printf ("pthread_attr_set_default failed for stacksize (%zu, %zu)\n",
+	      stacksize, stack);
       return (void *) (uintptr_t) 1;
     }
 
@@ -74,7 +62,7 @@ thr (void *unused)
       return (void *) (uintptr_t) 1;
     }
 
-  if (verify_result (&attr, 0))
+  if (verify_result (&attr))
     return (void *) (uintptr_t) 1;
 
   /* To verify that the attributes actually got applied.  */
@@ -85,7 +73,7 @@ thr (void *unused)
       return (void *) (uintptr_t) 1;
     }
 
-  return verify_result (&attr, 1);
+  return verify_result (&attr);
 }
 
 int
@@ -143,6 +131,20 @@ run_threads (void)
 int
 do_test (void)
 {
+  long pagesize = sysconf (_SC_PAGESIZE);
+
+  if (pagesize < 0)
+    {
+      printf ("sysconf failed: %s\n", strerror (errno));
+      return 1;
+    }
+
+  /* Perturb the size by a page so that we're not aligned on the 64K boundary.
+     pthread_create does this perturbation on x86 to avoid causing the 64k
+     aliasing conflict.  We want to prevent pthread_create from doing that
+     since it is not consistent for all architectures.  */
+  stacksize += pagesize;
+
   /* Run twice to ensure that we don't give a false positive.  */
   puts ("First iteration");
   int ret = run_threads ();

-----------------------------------------------------------------------

Summary of changes:
 nptl/tst-default-attr.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]