From patchwork Tue Jan 30 16:54:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 25693 Received: (qmail 69570 invoked by alias); 30 Jan 2018 16:54:57 -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 69559 invoked by uid 89); 30 Jan 2018 16:54:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: vmicros1.altlinux.org Date: Tue, 30 Jan 2018 19:54:53 +0300 From: "Dmitry V. Levin" To: libc-alpha@sourceware.org Subject: [PATCH] Tweak test-*exit-race tests to honor the maximum number of processes Message-ID: <20180130165453.GC26759@altlinux.org> Mail-Followup-To: libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline When the number of threads created by test-*exit-race tests is close to the maximum number of simultaneous processes per uid, these tests fail with the following diagnostics: error: xpthread_check_return.c:32: pthread_create: Resource temporarily unavailable Workaround this issue by limiting the number of threads created by these tests to sysconf (_SC_CHILD_MAX) / 2. Tested that these tests still fail reliably on x86_64 with glibc-2.26 and sysconf (_SC_CHILD_MAX) == 512. * stdlib/test-atexit-race-common.c: Include . (kNumThreads): Remove const qualifier. (do_test): Limit kNumThreads to sysconf (_SC_CHILD_MAX) / 2. --- ChangeLog | 6 ++++++ stdlib/test-atexit-race-common.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/stdlib/test-atexit-race-common.c b/stdlib/test-atexit-race-common.c index 4d7f911..7a65264 100644 --- a/stdlib/test-atexit-race-common.c +++ b/stdlib/test-atexit-race-common.c @@ -33,10 +33,11 @@ #include #include +#include #include -const size_t kNumThreads = 1024; -const size_t kNumHandlers = 1024; +static size_t kNumThreads = 1024; +static const size_t kNumHandlers = 1024; static void * threadfunc (void *unused) @@ -62,6 +63,11 @@ do_test (void) 128KiB for a maximum required VM size of 128MiB. */ xpthread_attr_setstacksize (&attr, 128 * 1024); + long nproc = sysconf (_SC_CHILD_MAX); + + if (nproc > 0 && nproc / 2 < kNumThreads) + kNumThreads = nproc / 2; + for (i = 0; i < kNumThreads; ++i) { xpthread_create (&attr, threadfunc, NULL); }