summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-09-22 19:46:04 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-15 08:55:55 +0300
commitc1a4423fd30f6ff4289be19786c9e76b5ac104a6 (patch)
tree976c5ed7e7f76947d03121197361a6a78abdc17d /drivers/char
parent638f84a718d99c68ce5a46d24283beecf5d48b7a (diff)
downloadlinux-c1a4423fd30f6ff4289be19786c9e76b5ac104a6.tar.xz
random: avoid reading two cache lines on irq randomness
commit 9ee0507e896b45af6d65408c77815800bce30008 upstream. In order to avoid reading and dirtying two cache lines on every IRQ, move the work_struct to the bottom of the fast_pool struct. add_ interrupt_randomness() always touches .pool and .count, which are currently split, because .mix pushes everything down. Instead, move .mix to the bottom, so that .pool and .count are always in the first cache line, since .mix is only accessed when the pool is full. Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/random.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 51006cce6e31..71563525340b 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -895,10 +895,10 @@ void __cold add_bootloader_randomness(const void *buf, size_t len)
EXPORT_SYMBOL_GPL(add_bootloader_randomness);
struct fast_pool {
- struct work_struct mix;
unsigned long pool[4];
unsigned long last;
unsigned int count;
+ struct work_struct mix;
};
static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = {