Re: [PATCH 1/2] random: use chacha20 for get_random_int/long

From: Jason A. Donenfeld
Date: Fri Jan 20 2017 - 10:39:12 EST


Hi Ted,

On Fri, Jan 20, 2017 at 3:28 PM, Theodore Ts'o <tytso@xxxxxxx> wrote:
> What I would probably do is just use one array and one array index,
> denominated in 32-bit words, and just grab two 32-bit words for the
> 64-bit case. Optimizing away the overhead of assembling two 32-bit
> words for a 64-bit word, and the possibility that we might have to
> touch two cache lines instead of one --- is it really worth it?

I was thinking that the issue isn't merely cache line and a slow down,
but that on some platforms, this could be an _illegal unaligned
access_. That means we'd need to rewrite the code to use the unaligned
access helpers or memcpy, and then it's really suboptimal, not to
mention ugly, since just indexing into an array like we do now is so
clean.

Jason