diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-04-13 14:11:27 -0500 |
---|---|---|
committer | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-04-13 14:11:27 -0500 |
commit | 13a601a0dfb468552c1eebf5c225392260f0bda2 (patch) | |
tree | b62ae63507237b19b4c2d996df205f6ae99d1270 | |
parent | eb8c932bac2e6c1273107b8a2721f382575b002a (diff) | |
download | glibc-13a601a0dfb468552c1eebf5c225392260f0bda2.zip glibc-13a601a0dfb468552c1eebf5c225392260f0bda2.tar.gz glibc-13a601a0dfb468552c1eebf5c225392260f0bda2.tar.bz2 |
tst-malloc-thread-exit: Use fewer system resources
(cherry picked from commit 2a38688932243b5b16fb12d84c7ac1138ce50363)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | malloc/tst-malloc-thread-exit.c | 29 |
2 files changed, 22 insertions, 14 deletions
@@ -1,5 +1,12 @@ 2016-04-13 Florian Weimer <fweimer@redhat.com> + * malloc/tst-malloc-thread-exit.c: Include test-skeleton.c early. + (do_test): Limit the number of arenas, so that we can use fewer + outer threads. Limit timeout to 3 seconds, in preparation for a + larger TIMEOUT value. + +2016-04-13 Florian Weimer <fweimer@redhat.com> + [BZ #19182] * malloc/arena.c (list_lock): Document lock ordering requirements. (free_list_lock): New lock. diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c index da7297e..7bce012 100644 --- a/malloc/tst-malloc-thread-exit.c +++ b/malloc/tst-malloc-thread-exit.c @@ -26,13 +26,17 @@ particularly related to the arena free list. */ #include <errno.h> +#include <malloc.h> #include <pthread.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#define TIMEOUT 7 +static int do_test (void); + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" static bool termination_requested; static int inner_thread_count = 4; @@ -156,20 +160,20 @@ outer_thread (void *closure) static int do_test (void) { - /* The number of top-level threads should be equal to the number of - arenas. See arena_get2. */ - long outer_thread_count = sysconf (_SC_NPROCESSORS_ONLN); - if (outer_thread_count >= 1) + /* The number of threads should be smaller than the number of + arenas, so that there will be some free arenas to add to the + arena free list. */ + enum { outer_thread_count = 2 }; + if (mallopt (M_ARENA_MAX, 8) == 0) { - /* See NARENAS_FROM_NCORES in malloc.c. */ - if (sizeof (long) == 4) - outer_thread_count *= 2; - else - outer_thread_count *= 8; + printf ("error: mallopt (M_ARENA_MAX) failed\n"); + return 1; } /* Leave some room for shutting down all threads gracefully. */ - int timeout = TIMEOUT - 2; + int timeout = 3; + if (timeout > TIMEOUT) + timeout = TIMEOUT - 1; pthread_t *threads = calloc (sizeof (*threads), outer_thread_count); if (threads == NULL) @@ -212,6 +216,3 @@ do_test (void) return 0; } - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" |