]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
random: remove batched entropy locking
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 28 Jan 2022 22:29:45 +0000 (23:29 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:22:55 +0000 (09:22 +0200)
commit941245fc4468911d9ecb9591e943837a3ff5c6aa
tree5f628e4663dc97e3c94a7516a4d296799983d613
parent1c785fbc3fd08314a9379c84fa9c5ada14390205
random: remove batched entropy locking

BugLink: https://bugs.launchpad.net/bugs/1981649
commit 77760fd7f7ae3dfd03668204e708d1568d75447d upstream.

Rather than use spinlocks to protect batched entropy, we can instead
disable interrupts locally, since we're dealing with per-cpu data, and
manage resets with a basic generation counter. At the same time, we
can't quite do this on PREEMPT_RT, where we still want spinlocks-as-
mutexes semantics. So we use a local_lock_t, which provides the right
behavior for each. Because this is a per-cpu lock, that generation
counter is still doing the necessary CPU-to-CPU communication.

This should improve performance a bit. It will also fix the linked splat
that Jonathan received with a PROVE_RAW_LOCK_NESTING=y.

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Suggested-by: Andy Lutomirski <luto@kernel.org>
Reported-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Tested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Link: https://lore.kernel.org/lkml/YfMa0QgsjCVdRAvJ@latitude/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/char/random.c