]> git.baikalelectronics.ru Git - kernel.git/commit
random: clear fast pool, crng, and batches in cpuhp bring up
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 13 Feb 2022 21:48:04 +0000 (22:48 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 21 Feb 2022 20:14:21 +0000 (21:14 +0100)
commitb6c2dbac9014cd950d0af3b84ef96562cf17e525
treee8c1a5fde507905e32020ba845136982f7643d92
parent37e29fe5c6bea44d15bfd1c93359f64c76b868e8
random: clear fast pool, crng, and batches in cpuhp bring up

For the irq randomness fast pool, rather than having to use expensive
atomics, which were visibly the most expensive thing in the entire irq
handler, simply take care of the extreme edge case of resetting count to
zero in the cpuhp online handler, just after workqueues have been
reenabled. This simplifies the code a bit and lets us use vanilla
variables rather than atomics, and performance should be improved.

As well, very early on when the CPU comes up, while interrupts are still
disabled, we clear out the per-cpu crng and its batches, so that it
always starts with fresh randomness.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Sultan Alsawaf <sultan@kerneltoast.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c
include/linux/cpuhotplug.h
include/linux/random.h
kernel/cpu.c