-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On a CM3+, the regenerate_ssh_host_keys script in rasapberrypi-sys-mods takes a very long time to run on kernel v6.1 #5390
Comments
I can confirm the regression - a 3B+ shows the same problem (I've not checked other models yet). |
Pi 4 seemed quick for me. |
On Pi4:
(spurts lots of random stuff). On Pi3+ nothing comes out. |
It's interesting that there should be a difference (which I'll investigate), but on the surface the problem appears to come from this upstream commit: 96cb9d0, the payload of which is: diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index e7dd457e9b22b..e98fcac578d66 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -71,7 +71,7 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
while ((rng_readl(priv, RNG_STATUS) >> 24) == 0) {
if (!wait)
return 0;
- cpu_relax();
+ hwrng_msleep(rng, 1000);
}
num_words = rng_readl(priv, RNG_STATUS) >> 24; i.e. wait for a whole second between reads. Dropping this to 1ms gives a big improvement:
But the reversion to
(note this is for 0.855s for 100,000 bytes as opposed to 15.025s for 10,000 bytes). I'm going to revert the patch for now, but we should investigate whether this is even needed - the purpose of the kthread the commit refers to seems to be to shovel data into the random number generator. |
A quick look at the process list shows that we're also running
whose documentation says:
@XECDesign Do we still need the explicit random number seeding in |
Surely that is a bug? I assuming author was thinking 1ms rather than 1s. Commit message says:
I feel "sleep for a bit" in a kernel driver context doesn't equate to a second. |
Florian can't have been awake that day. |
It's reverted for now. |
Hi, @ffainelli What's your opinion? |
Yeah, it runs on the very first boot, before systemd runs or has a chance to start rngd. |
I believe the RNG block has an interrupt. Looks like it's |
That would be a very invasive change, with patches to the driver and DTS files. The iproc_rng200 driver that's used on 2711 (hence the absence of a problem on Pi 4) waits for up to 500us, with the actual length governed by the amount of data that's required:
|
kernel: Revert hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax() See: raspberrypi/linux#5390 kernel: reboot: Use power off rather than busy spinning when halt is requested See: raspberrypi/linux#5385 kernel: imx296: Replace downstream driver with upstream See: raspberrypi/linux#5384 firmware: gencmd: Add a fallback to mailbox interface if vchiq is not available
kernel: Revert hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax() See: raspberrypi/linux#5390 kernel: reboot: Use power off rather than busy spinning when halt is requested See: raspberrypi/linux#5385 kernel: imx296: Replace downstream driver with upstream See: raspberrypi/linux#5384 firmware: gencmd: Add a fallback to mailbox interface if vchiq is not available
@JinShil the latest rpi-update kernel contains the revert so should avoid your issue. |
Thank you, I'll test tomorrow. rpi-update will provide us with a temporary workaround, but our OS creation scripts are based on pi-gen, so can you estimate when this fix might be available through apt? |
We don't have a scheduled date for the next apt update. |
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: raspberrypi#5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
See #5396 for a better fix. |
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: raspberrypi#5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
To install a trial build with the more intelligent sleeping, run |
I tested that today, and it seems to work fine. |
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: raspberrypi#5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Just to add another data point, also seeing this on an RPi3, booting the current RPi Lite image with the kernel and bootloader packages updated to
A timeline for the fixed version on apt here would indeed be nice, this is currently a blocker for providing up-to-date OctoPi images for OctoPrint. |
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
While waiting for random data, use sleeps that are proportional to the amount of data expected. Prevent indefinite waits by giving up if nothing is received for a second. See: #5390 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Describe the bug
On a CM3+, the
regenerate_ssh_host_keys
script inrasapberrypi-sys-mods
is taking a very long time to run after installing 6.1 via apt using our pi-gen-based OS creation script. The offending line appears to bedd if=/dev/hwrng of=/dev/urandom count=1 bs=4096 status=none
The same command runs in under a second on a CM4 or CM4S.
Steps to reproduce the behaviour
Using a CM3+, install a 64-bit Bullseye OS with kernel v6.1 and run the
regenerate_ssh_host_keys
script.Device (s)
Raspberry Pi CM3+, Raspberry Pi CM3+ Lite
System
OS was generated using a script based on pi-gen.
Kernel version 6.1.19-v8+
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: