[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a171166422a545a99ac815541018d44f@AcuMS.aculab.com>
Date: Fri, 25 Nov 2022 15:04:41 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Sandy Harris' <sandyinchina@...il.com>,
"Jason A. Donenfeld" <Jason@...c4.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>
Subject: RE: [PATCH] random: add 8-bit and 16-bit batches
From: Sandy Harris
> Sent: 25 November 2022 04:11
>
> On Thu, Sep 29, 2022 at 1:33 AM Jason A. Donenfeld <Jason@...c4.com> wrote:
> >
> > There are numerous places in the kernel that would be sped up by having
> > smaller batches. ...
>
> > void get_random_bytes(void *buf, size_t len);
> > +u8 get_random_u8(void);
> > +u16 get_random_u16(void);
> > u32 get_random_u32(void);
> > u64 get_random_u64(void);
> > static inline unsigned int get_random_int(void)
>
> To me, the 32-bit & 64-bit functions look like an
> obviously good idea. However, I cannot see
> that the 8-bit or 16-bit functions are needed.
>
> Even library functions like getchar() return an
> int & whatever you return, it is going to be
> handled as an int-sized item if it goes in a
> register, so what's the point?
They avoid 'using up' random values the callers wont use.
This can save expensive re-hashing (etc).
OTOH the return types should probably be u32 even though the
domain is smaller.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists