Skip to content

Commit 9ee0507

Browse files
committed
random: avoid reading two cache lines on irq randomness
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: 58340f8 ("random: defer fast pool mixing to worker") Reviewed-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent e78a802 commit 9ee0507

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,10 @@ EXPORT_SYMBOL_GPL(unregister_random_vmfork_notifier);
918918
#endif
919919

920920
struct fast_pool {
921-
struct work_struct mix;
922921
unsigned long pool[4];
923922
unsigned long last;
924923
unsigned int count;
924+
struct work_struct mix;
925925
};
926926

927927
static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = {

0 commit comments

Comments
 (0)