Re: [PATCH] poly1305: generic C can be faster on chips with slow unaligned access

From: David Miller
Date: Thu Nov 03 2016 - 13:08:58 EST


From: "Jason A. Donenfeld" <Jason@xxxxxxxxx>
Date: Thu, 3 Nov 2016 08:24:57 +0100

> Hi Herbert,
>
> On Thu, Nov 3, 2016 at 1:49 AM, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>> FWIW I'd rather live with a 6% slowdown than having two different
>> code paths in the generic code. Anyone who cares about 6% would
>> be much better off writing an assembly version of the code.
>
> Please think twice before deciding that the generic C "is allowed to
> be slow".

In any event no piece of code should be doing 32-bit word reads from
addresses like "x + 3" without, at a very minimum, going through the
kernel unaligned access handlers.

Yet that is what the generic C poly1305 code is doing, all over the
place.

We know explicitly that these offsets will not be 32-bit aligned, so
it is required that we use the helpers, or alternatively do things to
avoid these unaligned accesses such as using temporary storage when
the HAVE_EFFICIENT_UNALIGNED_ACCESS kconfig value is not set.