]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 13:58:34 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 13:58:34 +0000 (15:58 +0200)
added patches:
random-schedule-mix_interrupt_randomness-less-often.patch

queue-4.9/random-schedule-mix_interrupt_randomness-less-often.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/random-schedule-mix_interrupt_randomness-less-often.patch b/queue-4.9/random-schedule-mix_interrupt_randomness-less-often.patch
new file mode 100644 (file)
index 0000000..4e86835
--- /dev/null
@@ -0,0 +1,56 @@
+From 534d2eaf1970274150596fdd2bf552721e65d6b2 Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Thu, 16 Jun 2022 02:03:12 +0200
+Subject: random: schedule mix_interrupt_randomness() less often
+
+From: Jason A. Donenfeld <Jason@zx2c4.com>
+
+commit 534d2eaf1970274150596fdd2bf552721e65d6b2 upstream.
+
+It used to be that mix_interrupt_randomness() would credit 1 bit each
+time it ran, and so add_interrupt_randomness() would schedule mix() to
+run every 64 interrupts, a fairly arbitrary number, but nonetheless
+considered to be a decent enough conservative estimate.
+
+Since e3e33fc2ea7f ("random: do not use input pool from hard IRQs"),
+mix() is now able to credit multiple bits, depending on the number of
+calls to add(). This was done for reasons separate from this commit, but
+it has the nice side effect of enabling this patch to schedule mix()
+less often.
+
+Currently the rules are:
+a) Credit 1 bit for every 64 calls to add().
+b) Schedule mix() once a second that add() is called.
+c) Schedule mix() once every 64 calls to add().
+
+Rules (a) and (c) no longer need to be coupled. It's still important to
+have _some_ value in (c), so that we don't "over-saturate" the fast
+pool, but the once per second we get from rule (b) is a plenty enough
+baseline. So, by increasing the 64 in rule (c) to something larger, we
+avoid calling queue_work_on() as frequently during irq storms.
+
+This commit changes that 64 in rule (c) to be 1024, which means we
+schedule mix() 16 times less often. And it does *not* need to change the
+64 in rule (a).
+
+Fixes: 58340f8e952b ("random: defer fast pool mixing to worker")
+Cc: stable@vger.kernel.org
+Cc: Dominik Brodowski <linux@dominikbrodowski.net>
+Acked-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 |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/char/random.c
++++ b/drivers/char/random.c
+@@ -997,7 +997,7 @@ void add_interrupt_randomness(int irq)
+       if (new_count & MIX_INFLIGHT)
+               return;
+-      if (new_count < 64 && !time_is_before_jiffies(fast_pool->last + HZ))
++      if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ))
+               return;
+       if (unlikely(!fast_pool->mix.func))
index a2a5948449c8ca7b4ad9cd3a95490c6e46a7a340..06f3721768956666255029cca52d15d38dfe3ad2 100644 (file)
@@ -1 +1,2 @@
 vt-drop-old-font-ioctls.patch
+random-schedule-mix_interrupt_randomness-less-often.patch