From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by sourceware.org (Postfix) with ESMTPS id D29E2385782C for ; Fri, 29 Jul 2022 12:15:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D29E2385782C Received: by mail-vs1-xe2b.google.com with SMTP id b67so4345701vsc.1 for ; Fri, 29 Jul 2022 05:15:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=BXDMX139xReHhSVE3vzErGHq4MFtbfddUmG3DtWD3x8=; b=UW0+bdexRY7ga9kE5HY9tsHzHkHlcvv397/PecfDTdjNEYbzruUenfAsx/oAsVsqPK L5cK0lNWhSc3ckOvHk1n9EE0Z23kLODbT7LYPsh4XuZ/TZ8grIj4VHYDKwG+S84kgenb i50yQRbwExzIzt4zM/nCHvzokBly7Ii8Dfv4nBlFvo+0nLi1NAvQHMVAx0FcI5YvtCT5 2oTdLVCOr+3AORSTrCiqo8f3ShJhrAVnDwjmCpll3DHRv//LpevCpypGB1pG+ASoxZnS GIni//gMXAcyJoZyzMmIy6JI4zzQMwuIgJ4RHgTtr/Gxx2Hi75vhMhIvBS/jLJaoCUD5 bzlg== X-Gm-Message-State: AJIora9ille4Z/YvM1w4V3Had4LnbTtTKzHkIW5+ScZY8i56pCGeeG2s GetXlQRJxPxI5bEodUaMQtrRBw== X-Google-Smtp-Source: AGRyM1sxA3lblRRcaLG2vwg6zEFTi5Hq50ATdQnCKIdxHc+e4i26D2CMwbJfYn6LJbYsBWRwwaXjBQ== X-Received: by 2002:a05:6102:7b7:b0:358:5255:5cb8 with SMTP id x23-20020a05610207b700b0035852555cb8mr1059851vsg.24.1659096916051; Fri, 29 Jul 2022 05:15:16 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:1e34:8c1:7b8a:41d4:61c7? ([2804:431:c7cb:1e34:8c1:7b8a:41d4:61c7]) by smtp.gmail.com with ESMTPSA id e25-20020a056102355900b0036354995760sm369532vss.13.2022.07.29.05.15.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 05:15:15 -0700 (PDT) Message-ID: <1b28cb73-2140-24ca-ca44-6cbb61156c7c@linaro.org> Date: Fri, 29 Jul 2022 09:15:12 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v3] stdlib: Tuned down tst-arc4random-thread internal parameters Content-Language: en-US To: Szabolcs Nagy Cc: libc-alpha@sourceware.org, Florian Weimer , Carlos O'Donell References: <20220728124410.38944-1-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, 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-List-Received-Date: Fri, 29 Jul 2022 12:15:19 -0000 On 28/07/22 11:14, Szabolcs Nagy wrote: > The 07/28/2022 09:44, Adhemerval Zanella wrote: >> 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. > > thanks, this looks good. > > Reviewed-by: Szabolcs Nagy Thanks, I will commit this shortly since this is most likely required to have a clean make check. > >> --- >> stdlib/tst-arc4random-thread.c | 24 ++++++++++++++++++------ >> 1 file changed, 18 insertions(+), 6 deletions(-) >> >> diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c >> index 3373d4d446..daba828fad 100644 >> --- a/stdlib/tst-arc4random-thread.c >> +++ b/stdlib/tst-arc4random-thread.c >> @@ -17,23 +17,23 @@ >> . */ >> >> #include >> +#include >> #include >> -#include >> #include >> +#include >> #include >> #include >> #include >> #include >> >> /* Number of arc4random_buf calls per thread. */ >> -enum { count_per_thread = 5000 }; >> +enum { count_per_thread = 2048 }; >> >> /* 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 +331,18 @@ 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 schedulable CPUs. */ >> + cpu_set_t cpuset; >> + if (sched_getaffinity (0, sizeof cpuset, &cpuset) == 0) >> + { >> + unsigned int ncpus = CPU_COUNT (&cpuset); >> + /* Limit the number to not overload the system. */ >> + outer_threads = (ncpus / 2) / inner_threads ?: 1; >> + } >> + >> + 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); >> -- >> 2.34.1 >>