From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 3EE043830898 for ; Tue, 28 Jun 2022 12:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3EE043830898 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-B-bXZ7qJNcqdWyGXJUB7Iw-1; Tue, 28 Jun 2022 08:01:59 -0400 X-MC-Unique: B-bXZ7qJNcqdWyGXJUB7Iw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD54781D9DA; Tue, 28 Jun 2022 12:01:58 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.0]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00600C28115; Tue, 28 Jun 2022 12:01:57 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Subject: Re: [PATCH v6 03/10] benchtests: Add arc4random benchtest References: <20220518191424.3630729-1-adhemerval.zanella@linaro.org> <20220518191424.3630729-4-adhemerval.zanella@linaro.org> Date: Tue, 28 Jun 2022 14:01:56 +0200 In-Reply-To: <20220518191424.3630729-4-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Wed, 18 May 2022 16:14:17 -0300") Message-ID: <87o7ydf13f.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 12:02:06 -0000 * Adhemerval Zanella via Libc-alpha: > 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 @@ > +/* Prevent compiler to optimize away call. */ > +#define DO_NOT_OPTIMIZE(__value)=09=09\ > + ({=09=09=09=09=09=09\ > + __typeof (__value) __v =3D (__value);=09=09\ > + asm volatile("" : : "r,m" (__v) : "memory");\ > + }) Missing space after =E2=80=9Cvolatile=E2=80=9D. Maybe this should be a generic building block for benchtests? > +static void > +run_bench (json_ctx_t *json_ctx, const char *name, > +=09 char *const*fnames, size_t fnameslen, > +=09 void (*bench)(json_ctx_t *ctx)) Missing space between =E2=80=9C)(=E2=80=9D. > 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 m= aximum > - 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 kerne= l > 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. T= he > + latter does not handle direct clone calls, nor vfork or _Fork (arc4ra= ndom > + is not async-signal-safe due to the internal lock usage). */ > static void > arc4random_init (uint8_t *buf) > { I think this belongs into some other patch. Thanks, Florian