From ed05d6505574e608e54321ab8d5416085a512a0a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 13 Oct 2022 18:27:16 +0200 Subject: [PATCH] 4.19-stable patches added patches: random-avoid-reading-two-cache-lines-on-irq-randomness.patch --- ...ng-two-cache-lines-on-irq-randomness.patch | 38 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 39 insertions(+) create mode 100644 queue-4.19/random-avoid-reading-two-cache-lines-on-irq-randomness.patch diff --git a/queue-4.19/random-avoid-reading-two-cache-lines-on-irq-randomness.patch b/queue-4.19/random-avoid-reading-two-cache-lines-on-irq-randomness.patch new file mode 100644 index 00000000000..9ffb51de636 --- /dev/null +++ b/queue-4.19/random-avoid-reading-two-cache-lines-on-irq-randomness.patch @@ -0,0 +1,38 @@ +From 9ee0507e896b45af6d65408c77815800bce30008 Mon Sep 17 00:00:00 2001 +From: "Jason A. Donenfeld" +Date: Thu, 22 Sep 2022 18:46:04 +0200 +Subject: random: avoid reading two cache lines on irq randomness + +From: Jason A. Donenfeld + +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 +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Greg Kroah-Hartman +--- + drivers/char/random.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -890,10 +890,10 @@ void __init add_bootloader_randomness(co + } + + 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) = { diff --git a/queue-4.19/series b/queue-4.19/series index 78a202d4956..7dc1591f410 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -24,3 +24,4 @@ alsa-hda-fix-position-reporting-on-poulsbo.patch scsi-stex-properly-zero-out-the-passthrough-command-structure.patch usb-serial-qcserial-add-new-usb-id-for-dell-branded-em7455.patch random-restore-o_nonblock-support.patch +random-avoid-reading-two-cache-lines-on-irq-randomness.patch -- 2.47.3