[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y046F2pGjC0apna0@zx2c4.com>
Date: Mon, 17 Oct 2022 23:31:03 -0600
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Eric Biggers <ebiggers@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
sneves@....uc.pt
Subject: Re: [PATCH] random: use rejection sampling for uniform bounded
random integers
On Mon, Oct 17, 2022 at 11:27:17AM -0700, Eric Biggers wrote:
> On Sun, Oct 16, 2022 at 08:37:53PM -0600, Jason A. Donenfeld wrote:
> > In order to be efficient, we implement a kernel-specific variant of
> > Daniel Lemire's algorithm from "Fast Random Integer Generation in an
> > Interval", linked below. The kernel's variant takes advantage of
> > constant folding to avoid divisions entirely in the vast majority of
> > cases, works on both 32-bit and 64-bit architectures, and requests a
> > minimal amount of bytes from the RNG.
> >
> > Link: https://arxiv.org/pdf/1805.10941.pdf
>
> Thanks for doing this! Your code looks correct, but it was hard for me to
> understand until I read the paper that is linked to. Could you include a brief
> comment in the code that explains the algorithm? Also, though the code looks
> correct, I assume that you've also explicitly tested that each of the four code
> paths produce uniform random numbers as intended?
Yes, I've tested those, and they work. (Threw a lot of cores and ram at
it.)
I could include a comment, sure. What do you have in mind? A
line-by-line thing, or just a short blurb at the top of the function?
Jason
Powered by blists - more mailing lists