Skip to content

Commit 585cd5f

Browse files
committed
random: add 8-bit and 16-bit batches
There are numerous places in the kernel that would be sped up by having smaller batches. Currently those callsites do `get_random_u32() & 0xff` or similar. Since these are pretty spread out, and will require patches to multiple different trees, let's get ahead of the curve and lay the foundation for `get_random_u8()` and `get_random_u16()`, so that it's then possible to start submitting conversion patches leisurely. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 37608ba commit 585cd5f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

drivers/char/random.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ EXPORT_SYMBOL(get_random_ ##type);
506506

507507
DEFINE_BATCHED_ENTROPY(u64)
508508
DEFINE_BATCHED_ENTROPY(u32)
509+
DEFINE_BATCHED_ENTROPY(u16)
510+
DEFINE_BATCHED_ENTROPY(u8)
509511

510512
#ifdef CONFIG_SMP
511513
/*

include/linux/random.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ static inline int unregister_random_vmfork_notifier(struct notifier_block *nb) {
3838
#endif
3939

4040
void get_random_bytes(void *buf, size_t len);
41+
u8 get_random_u8(void);
42+
u16 get_random_u16(void);
4143
u32 get_random_u32(void);
4244
u64 get_random_u64(void);
4345
static inline unsigned int get_random_int(void)

0 commit comments

Comments
 (0)