public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH v6 03/10] benchtests: Add arc4random benchtest
Date: Tue, 28 Jun 2022 14:01:56 +0200	[thread overview]
Message-ID: <87o7ydf13f.fsf@oldenburg.str.redhat.com> (raw)
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")

* 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)		\
> +  ({						\
> +    __typeof (__value) __v = (__value);		\
> +    asm volatile("" : : "r,m" (__v) : "memory");\
> +  })

Missing space after “volatile”.

Maybe this should be a generic building block for benchtests?

> +static void
> +run_bench (json_ctx_t *json_ctx, const char *name,
> +	   char *const*fnames, size_t fnameslen,
> +	   void (*bench)(json_ctx_t *ctx))

Missing space between “)(”.


> 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 <sys/param.h>
>  #include <sys/random.h>
>  
> -/* 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.
>  
>     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");
>  }
>  
> -/* 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)
>  {

I think this belongs into some other patch.

Thanks,
Florian


  reply	other threads:[~2022-06-28 12:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18 19:14 [PATCH v6 00/10] Add arc4random support Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 01/10] stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417) Adhemerval Zanella
2022-06-02  9:44   ` Yann Droneaud
2022-06-10 17:26     ` Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 02/10] stdlib: Add arc4random tests Adhemerval Zanella
2022-06-28 11:59   ` Florian Weimer
2022-06-28 16:58     ` Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 03/10] benchtests: Add arc4random benchtest Adhemerval Zanella
2022-06-28 12:01   ` Florian Weimer [this message]
2022-06-28 17:06     ` Adhemerval Zanella
2022-06-28 17:13   ` Noah Goldstein
2022-06-28 17:14     ` Noah Goldstein
2022-06-28 17:22       ` Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 04/10] aarch64: Add optimized chacha20 Adhemerval Zanella
2022-06-28 12:03   ` Florian Weimer
2022-06-28 17:39     ` Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 05/10] x86: Add SSE2 " Adhemerval Zanella
2022-05-18 20:44   ` Noah Goldstein
2022-05-18 19:14 ` [PATCH v6 06/10] x86: Add AVX2 " Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 07/10] powerpc64: Add " Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 08/10] s390x: " Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 09/10] stdlib: Add TLS optimization to arc4random Adhemerval Zanella
2022-06-28 12:19   ` Florian Weimer
2022-06-28 19:45     ` Adhemerval Zanella
2022-05-18 19:14 ` [PATCH v6 10/10] manual: Add documentation for arc4random functions Adhemerval Zanella
2022-06-28 12:09   ` Florian Weimer
2022-06-28 19:15     ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7ydf13f.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).