random: avoid reading two cache lines on irq randomness
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 22 Sep 2022 16:46:04 +0000 (18:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Oct 2022 05:59:02 +0000 (07:59 +0200)
commit984faa6fc759037734fae93e4a0f7662a20709f4
tree8d5ed8765ed8af76f8e76fe2b1eba9f0f46a1720
parenta937c59863d7d0dd6e936210809a289cfa7dbb5e
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>
drivers/char/random.c