From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id CDD39385740D for ; Tue, 28 Jun 2022 17:06:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CDD39385740D Received: by mail-oi1-x22b.google.com with SMTP id l81so18037891oif.9 for ; Tue, 28 Jun 2022 10:06:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=wYpK+XVKtPu/SDeBjPbMU0s/FMy22+uDprqo1PiZISo=; b=4vXWYEARhv5p3z2ZsmPhQ1+5HHuRwFroBH0jLW+jB/9an0qvGMC73liK246ZS7eg0I bM8M8BW8XSL1m2spBPUjNHB98K2xQBVvxzfPn/FGQCIlVRl0C6RMP1hAKxipiyxHLCOW TMl5PRR614glrVewnPqnvIjgEltB6mWhvQvcTUstxmXNiJrsIk6cGLJjfoq09E2pPHcs nFqmKHIMb6mSkkTEh9xNxc5EFSEO5F0XU4070CIf6Tdi3yjuCOJ64Uio65R5EuWlwTik nAQNfq6uZqO0ugqMzM4hvtOhQN0WMte90Vls0fP7PiYAxgJ03Iq+IHonPElMgTIlGeow y/wQ== X-Gm-Message-State: AJIora/5U9sk/ISOQoh6O3RwXxG4Qd7PlQHrZoBJjmcwPi4y1DT+l4YR E9FafyPBjdIGDdpCpOZXowWVFw== X-Google-Smtp-Source: AGRyM1sY2FsyeHPkD7FCxEbxR07ibYb8yf8ISHOWwls7p1PXVOsBb3sCjPiAjuvKqt2C21qRlCFf7Q== X-Received: by 2002:a05:6808:1916:b0:335:5b1e:2594 with SMTP id bf22-20020a056808191600b003355b1e2594mr395511oib.129.1656436016010; Tue, 28 Jun 2022 10:06:56 -0700 (PDT) Received: from smtpclient.apple ([2804:431:c7ca:6d95:25db:29b6:be9b:9202]) by smtp.gmail.com with ESMTPSA id u6-20020a056870304600b001010307ef04sm9878861oau.33.2022.06.28.10.06.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 10:06:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [PATCH v6 03/10] benchtests: Add arc4random benchtest From: Adhemerval Zanella In-Reply-To: <87o7ydf13f.fsf@oldenburg.str.redhat.com> Date: Tue, 28 Jun 2022 14:06:53 -0300 Cc: Adhemerval Zanella via Libc-alpha Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220518191424.3630729-1-adhemerval.zanella@linaro.org> <20220518191424.3630729-4-adhemerval.zanella@linaro.org> <87o7ydf13f.fsf@oldenburg.str.redhat.com> To: Florian Weimer X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-12.7 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, T_SCC_BODY_TEXT_LINE 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: Tue, 28 Jun 2022 17:06:58 -0000 > On 28 Jun 2022, at 09:01, Florian Weimer wrote: >=20 > * Adhemerval Zanella via Libc-alpha: >=20 >> diff --git a/benchtests/bench-arc4random.c = b/benchtests/bench-arc4random.c >> new file mode 100644 >> index 0000000000..626f2ba48c >> --- /dev/null >> +++ b/benchtests/bench-arc4random.c >> @@ -0,0 +1,224 @@ >=20 >> +/* Prevent compiler to optimize away call. */ >> +#define DO_NOT_OPTIMIZE(__value) \ >> + ({ \ >> + __typeof (__value) __v =3D (__value); \ >> + asm volatile("" : : "r,m" (__v) : "memory");\ >> + }) >=20 > Missing space after =E2=80=9Cvolatile=E2=80=9D. Ack. >=20 > Maybe this should be a generic building block for benchtests? Indeed, I moved it to benchtests/bench-util.h. >=20 >> +static void >> +run_bench (json_ctx_t *json_ctx, const char *name, >> + char *const*fnames, size_t fnameslen, >> + void (*bench)(json_ctx_t *ctx)) >=20 > Missing space between =E2=80=9C)(=E2=80=9D. Ack. >=20 >=20 >> diff --git a/stdlib/arc4random.c b/stdlib/arc4random.c >> index f6553dfd7d..74c917b9b9 100644 >> --- a/stdlib/arc4random.c >> +++ b/stdlib/arc4random.c >> @@ -25,9 +25,9 @@ >> #include >> #include >>=20 >> -/* Besides the cipher state 'ctx', it keeps two counters: 'have' is = the >> - current valid bytes not yet consumed in 'buf', while 'count' is = the maximum >> - number of bytes until a reseed. >> +/* arc4random keeps two counters: 'have' is the current valid bytes = not yet >> + consumed in 'buf' while 'count' is the maximum number of bytes = until a >> + reseed. >>=20 >> Both the initial seed and reseed try to obtain entropy from the = kernel >> and abort the process if none could be obtained. >> @@ -81,10 +81,10 @@ arc4random_getrandom_failure (void) >> __libc_fatal ("Fatal glibc error: Cannot get entropy for = arc4random\n"); >> } >>=20 >> -/* Fork detection is done by checking if MADV_WIPEONFORK supported. = If not >> - the fork callback will reset the state on the fork call. It does = not >> - handle direct clone calls, nor vfork or _Fork (arc4random is not >> - async-signal-safe due the internal lock usage). */ >> +/* If the kernel supports MADV_WIPEONFORK it is used to provide fork >> + detection. Otherwise, the state is resetied with an atfork = handler. The >> + latter does not handle direct clone calls, nor vfork or _Fork = (arc4random >> + is not async-signal-safe due to the internal lock usage). */ >> static void >> arc4random_init (uint8_t *buf) >> { >=20 > I think this belongs into some other patch. Indeed, I will fix it. >=20 > Thanks, > Florian >=20