linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	x86@kernel.org, Nadia Heninger <nadiah@cs.ucsd.edu>,
	Thomas Ristenpart <ristenpart@cornell.edu>,
	Theodore Ts'o <tytso@mit.edu>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH RFC v1] random: implement getrandom() in vDSO
Date: Sun, 31 Jul 2022 02:23:49 +0200	[thread overview]
Message-ID: <YuXLlUZ8EzvZB43U@zx2c4.com> (raw)
In-Reply-To: <YuXCpyULk6jFgGV5@zx2c4.com>

On Sun, Jul 31, 2022 at 01:45:43AM +0200, Jason A. Donenfeld wrote:
> So, anyway, if I do muster a v2 of this (perhaps just to see the idea
> through), the API might split in two to something like:
> 
>   void *getrandom_allocate_states([inout] size_t *number_of_states, [out] size_t *length_per_state);
>   ssize_t getrandom(void *state, void *buffer, size_t len, unsigned long flags);
> 
> User code will call getrandom_allocate_state(), which will allocate
> enough pages to hold *number_of_states, and return the size of each one
> in length_per_state and the number actually allocated back in
> number_of_states. The result can then be sliced up by that size, and
> passed to getrandom(). So glibc or whatever would presumably allocate
> one per thread, and handle any reentrancy/locking around it.
> 
> Or some other variation on that. I'm sure you hate those function
> signatures. Everybody loves to bikeshed APIs, right? There's plenty to
> be tweaked. But that's anyhow about where my thinking is for a potential
> v2.

Doing this also doubled performance, perhaps unsurprisingly, as that
getcpu() operation wasn't free.

For uint32_t generation:

   vdso: 25000000 times in 0.289876265 seconds
syscall: 25000000 times in 4.296636025 seconds

  reply	other threads:[~2022-07-31  0:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 14:55 [PATCH RFC v1] random: implement getrandom() in vDSO Jason A. Donenfeld
2022-07-29 20:19 ` Florian Weimer
2022-07-29 22:06   ` Jason A. Donenfeld
2022-07-30 15:48 ` Linus Torvalds
2022-07-30 23:45   ` Jason A. Donenfeld
2022-07-31  0:23     ` Jason A. Donenfeld [this message]
2022-07-31  1:31       ` [PATCH RFC v2] " Jason A. Donenfeld
2022-08-01  8:48         ` Florian Weimer
2022-08-01 12:49           ` Jason A. Donenfeld
2022-08-01 13:29             ` Jason A. Donenfeld
2022-08-01 13:00         ` Jason A. Donenfeld
2022-08-01 20:48         ` Thomas Gleixner
2022-08-01 23:41           ` Jason A. Donenfeld
2022-08-02  0:12             ` Jason A. Donenfeld
2022-08-01 19:30     ` [PATCH RFC v1] " Thomas Gleixner
2022-08-01 23:16       ` Jason A. Donenfeld
2022-08-02 13:46         ` Thomas Gleixner
2022-08-02 13:59           ` Jason A. Donenfeld
2022-08-02 15:14             ` Thomas Gleixner
2022-08-02 15:26               ` Jason A. Donenfeld
2022-08-02 22:27                 ` Thomas Gleixner
2022-08-04 15:23                   ` Jason A. Donenfeld
2022-08-04 16:08                     ` Jeffrey Walton
2022-08-04 23:11                     ` Thomas Gleixner
2022-08-17  8:20                   ` Peter Zijlstra
2022-08-05  8:36               ` Florian Weimer

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=YuXLlUZ8EzvZB43U@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nadiah@cs.ucsd.edu \
    --cc=ristenpart@cornell.edu \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=vincenzo.frascino@arm.com \
    --cc=x86@kernel.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 NNTP newsgroup(s).