This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] tst-malloc-thread-exit: run less aggressively
- From: Chris Metcalf <cmetcalf at ezchip dot com>
- To: <libc-alpha at sourceware dot org>, Florian Weimer <fweimer at redhat dot com>
- Cc: Chris Metcalf <cmetcalf at ezchip dot com>
- Date: Tue, 19 Jan 2016 14:58:58 -0500
- Subject: [PATCH] tst-malloc-thread-exit: run less aggressively
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none;ezchip.com; dmarc=none action=none header.from=ezchip.com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
On a 64-bit machine, the previous code would run up to
5 x 8 x NPROCS threads, or 2,880 threads on a 72-core TILE-Gx.
But since typically userspace runs with an RLIMIT_NPROC value
of 1024, the test will fail on such a machine. Instead, bound
the outer thread count to 200, rather than 8 x NPROCS, so that
the total number of threads created is max 1000. This may still
be a little risky when running in a "make -j check" context but
should at least pass when run separately to confirm a FAIL.
Also, bump up the timeout from 7 to 20, since it takes about
17 seconds on a 72-core TILE-Gx machine. Start trying to exit
threads at a hard 5-second point rather than waiting until two
seconds before the timeout, since the extra time seems to be
mainly in quiescing and joining all the outstanding threads.
---
Can I push this for 2.23? It fixes a test failure for tilegx.
ChangeLog | 5 +++++
malloc/tst-malloc-thread-exit.c | 10 ++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
2016-01-19 Chris Metcalf <cmetcalf@ezchip.com>
* malloc/tst-malloc-thread-exit.c (TIMEOUT): Bump up to 20.
Also clamp thread count to under 1024.
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index f4aa21af8668..16464e5dfcde 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <unistd.h>
-#define TIMEOUT 7
+#define TIMEOUT 20
static bool termination_requested;
static int inner_thread_count = 4;
@@ -168,8 +168,10 @@ do_test (void)
outer_thread_count *= 8;
}
- /* Leave some room for shutting down all threads gracefully. */
- int timeout = TIMEOUT - 2;
+ /* Respect typical non-root RLIMIT_NPROC of 1,024 processes. */
+ long max_outer_thread_count = 200;
+ if (outer_thread_count > max_outer_thread_count)
+ outer_thread_count = max_outer_thread_count;
pthread_t *threads = calloc (sizeof (*threads), outer_thread_count);
if (threads == NULL)
@@ -189,7 +191,7 @@ do_test (void)
}
}
- struct timespec ts = {timeout, 0};
+ struct timespec ts = {5, 0};
if (nanosleep (&ts, NULL))
{
printf ("error: error: nanosleep: %m\n");
--
2.1.2