From patchwork Wed Jul 27 12:06:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 56366 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF81B385703F for ; Wed, 27 Jul 2022 12:06:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF81B385703F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1658923587; bh=D95F8qUkf4HQteqemaOuykBVG5I07bbyh0oCI6sUVYs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=EwujlPsanIGKBhenJnUwuOU1SgdDbhk6+k4PJzg3oeAaDnRjjArRO+9kr6gzHsN/R iLPoDSEdhAgGfwhKqmgakWhC2K681qLUU4OeJU6RxDKdS2bRL8eLcaWYBOcYhgpyaB AsQhkvBMafwWSGf6oNnv4shI3IJ0un/MfBeMGJvM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 0C7783857001 for ; Wed, 27 Jul 2022 12:06:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C7783857001 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-10d6ddda695so22365960fac.0 for ; Wed, 27 Jul 2022 05:06:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=D95F8qUkf4HQteqemaOuykBVG5I07bbyh0oCI6sUVYs=; b=0V+4ycHxTNQ7nntC+vq9/NCNsNEraIjbQyjyy71pubjjCZmPbD49VcSDxD3B0FCAGl Ju1FEclnUMGpwAqw2HBoptC2wMF3cBdN+72SsnaSvv1cmhV0Fglq8yqp7AHsmrWGkhMu UlCJZgHP2iZ27vpCFaYz1GR5PIh/vIlu2Rs9NS03mBQfq+mkR+Ve2GlnnFfhDeADtjxU wuI36ROt6w8NuqNZjbl/YdBf/jIBzKRQFK1tzvkWp9Gp5HpU0KsnIZCy42VrW7sPV06P LoruthqujybJFM/k9f7ldlwcB1V9sO+9iaDX4BhSXlq7s32ZcEvMRXh8S0H24BYfC86/ tP3Q== X-Gm-Message-State: AJIora9USdw9jXqmBUDTObTUgAgQrg7zlghWpzzKO3W+Uwanx9z6NmdM FR2elUF06NjuKC4mJ4CKJOFO0CWtAghkiw== X-Google-Smtp-Source: AGRyM1u1tJ0s9hTaRexnLdJWxKC2i1Ft0VmtW+wQHy+i9Kkv9xVSx+rNEQU2HnhoP5eFlxBMbAhexQ== X-Received: by 2002:a05:6870:581d:b0:101:dc4f:51 with SMTP id r29-20020a056870581d00b00101dc4f0051mr1925887oap.247.1658923566286; Wed, 27 Jul 2022 05:06:06 -0700 (PDT) Received: from mandiga.. ([2804:431:c7cb:8ded:40b4:899c:8c0b:f670]) by smtp.gmail.com with ESMTPSA id w138-20020acaad90000000b00339c7af0e8esm7051301oie.51.2022.07.27.05.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 05:06:05 -0700 (PDT) To: libc-alpha@sourceware.org, Florian Weimer , "Jason A . Donenfeld" , Carlos O'Donell Subject: [PATCH] stdlib: Tuned down tst-arc4random-thread internal parameters Date: Wed, 27 Jul 2022 09:06:00 -0300 Message-Id: <20220727120600.2003708-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" With new arc4random implementation, the internal parameters might require a lot of runtime and/or trigger some contention on older kernels (which might trigger spurious timeout failures). Also, since we are now testing getrandom entropy instead of an userspace RNG, there is no much need to extensive testing. With this change the tst-arc4random-thread goes from about 1m to 5s on a Ryzen 9 with 5.15.0-41-generic. Checked on x86_64-linux-gnu. --- stdlib/tst-arc4random-thread.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c index 3373d4d446..9d25f3526b 100644 --- a/stdlib/tst-arc4random-thread.c +++ b/stdlib/tst-arc4random-thread.c @@ -24,16 +24,19 @@ #include #include #include +#include /* Number of arc4random_buf calls per thread. */ -enum { count_per_thread = 5000 }; +enum { count_per_thread = 2048 }; + +/* Number of threads in subprocess. */ +enum { fork_threads = 3 }; /* Number of threads computing randomness. */ -enum { inner_threads = 5 }; +enum { inner_threads = 4 }; -/* Number of threads launching other threads. Chosen as to not to - overload the system. */ -enum { outer_threads = 7 }; +/* Number of threads launching other threads. */ +static int outer_threads = 1; /* Number of launching rounds performed by the outer threads. */ enum { outer_rounds = 10 }; @@ -331,6 +334,15 @@ do_test_func (const char *fname, void (*func)(unsigned char *, size_t)) static int do_test (void) { + /* Do not run more threads than the maximum of online CPUs. */ + long int cpus = sysconf (_SC_NPROCESSORS_ONLN); + if (cpus != -1) + /* Limit the number to not overload the system. */ + outer_threads = (cpus / 2) / inner_threads; + + printf ("info: outer_threads=%d inner_threads=%d\n", outer_threads, + inner_threads); + do_test_func ("arc4random", generate_arc4random); do_test_func ("arc4random_buf", generate_arc4random_buf); do_test_func ("arc4random_uniform", generate_arc4random_uniform);