From patchwork Mon Feb 8 14:41:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 10759 Received: (qmail 79867 invoked by alias); 8 Feb 2016 14:41:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 79852 invoked by uid 89); 8 Feb 2016 14:41:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2101, sk:tst-mal, sk:tstmal, UD:pthread.h X-HELO: mx1.redhat.com To: GNU C Library From: Florian Weimer Subject: [PATCH] tst-malloc-thread-exit: Use fewer system resources Message-ID: <56B8A916.6090309@redhat.com> Date: Mon, 8 Feb 2016 15:41:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 As discussed with Chris Metcalf: https://sourceware.org/ml/libc-alpha/2016-01/msg00636.html Thanks, Florian 2016-02-08 Florian Weimer * 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. diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c index f4aa21a..c392051 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 +#include #include #include #include #include #include -#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; @@ -153,23 +157,24 @@ outer_thread (void *closure) return NULL; } + 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 +217,3 @@ do_test (void) return 0; } - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c"