[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170121001013.6vtxpuaqplwnvwaz@thunk.org>
Date: Fri, 20 Jan 2017 19:10:13 -0500
From: Theodore Ts'o <tytso@....edu>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Hannes Frederic Sowa <hannes@...essinduktion.org>,
Andy Lutomirski <luto@...capital.net>
Subject: Re: [PATCH 1/2] random: use chacha20 for get_random_int/long
On Fri, Jan 20, 2017 at 04:38:59PM +0100, Jason A. Donenfeld wrote:
> 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.
Why would there be an unaligned access? What I was suggesting was an
array of u32, and we just do two separate u32 accesses with a shift in
the case of get_random_u64. There's nothing illegal about that.
u64 retval;
retval = (array[pointer] << 32) + array[pointer+1];
pointer += 2;
This is not terribly suboptimal nor terribly ugly.
- Ted
Powered by blists - more mailing lists