From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: stable@vger.kernel.org, gregkh@linuxfoundation.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: [PATCH stable 2/3] random: avoid reading two cache lines on irq randomness
Date: Thu, 13 Oct 2022 09:36:53 -0600 [thread overview]
Message-ID: <20221013153654.1397691-3-Jason@zx2c4.com> (raw)
In-Reply-To: <20221013153654.1397691-1-Jason@zx2c4.com>
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>
---
drivers/char/random.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 39f811f3dcc9..6dd9544930f8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -890,10 +890,10 @@ void __init add_bootloader_randomness(const void *buf, size_t len)
}
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) = {
--
2.37.3
next prev parent reply other threads:[~2022-10-13 15:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 15:36 [PATCH stable 0/3] recent failed backports for the rng Jason A. Donenfeld
2022-10-13 15:36 ` [PATCH stable 1/3] random: restore O_NONBLOCK support Jason A. Donenfeld
2022-10-13 16:20 ` Greg KH
2022-10-13 16:22 ` Greg KH
2022-10-13 16:32 ` [PATCH stable 4.9.y] " Jason A. Donenfeld
2022-10-13 17:02 ` Greg KH
2022-10-13 15:36 ` Jason A. Donenfeld [this message]
2022-10-13 15:36 ` [PATCH stable 3/3] random: use expired timer rather than wq for mixing fast pool Jason A. Donenfeld
2022-10-13 16:18 ` [PATCH stable 0/3] recent failed backports for the rng Greg KH
2022-10-13 16:29 ` Jason A. Donenfeld
2022-10-13 16:54 ` Greg KH
2022-10-13 17:01 ` Jason A. Donenfeld
2022-10-13 17:07 ` [PATCH stable 4.9.y 4.14.y] random: use expired timer rather than wq for mixing fast pool Jason A. Donenfeld
2022-10-13 17:17 ` Greg KH
2022-10-13 16:30 ` [PATCH stable 0/3] recent failed backports for the rng Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221013153654.1397691-3-Jason@zx2c4.com \
--to=jason@zx2c4.com \
--cc=gregkh@linuxfoundation.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox