* [PATCH] random: do not take pool spinlock at boot
@ 2022-02-12 0:28 Jason A. Donenfeld
2022-02-13 6:55 ` Dominik Brodowski
2022-02-21 5:34 ` Eric Biggers
0 siblings, 2 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2022-02-12 0:28 UTC (permalink / raw)
To: linux, linux-kernel; +Cc: Jason A. Donenfeld
Since rand_initialize() is run while interrupts are still off and
nothing else is running, we don't need to repeatedly take and release
the pool spinlock, especially in the RDSEED loop.
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
Dominik - I'm still a bit unclear about early boot semantics that you
seem to know well. Is this patch correct?
drivers/char/random.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d4b692c9de68..8088348190e6 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -966,10 +966,10 @@ int __init rand_initialize(void)
rv = random_get_entropy();
arch_init = false;
}
- mix_pool_bytes(&rv, sizeof(rv));
+ _mix_pool_bytes(&rv, sizeof(rv));
}
- mix_pool_bytes(&now, sizeof(now));
- mix_pool_bytes(utsname(), sizeof(*(utsname())));
+ _mix_pool_bytes(&now, sizeof(now));
+ _mix_pool_bytes(utsname(), sizeof(*(utsname())));
extract_entropy(base_crng.key, sizeof(base_crng.key));
++base_crng.generation;
--
2.35.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] random: do not take pool spinlock at boot
2022-02-12 0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
@ 2022-02-13 6:55 ` Dominik Brodowski
2022-02-21 5:34 ` Eric Biggers
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Brodowski @ 2022-02-13 6:55 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: linux-kernel
Am Sat, Feb 12, 2022 at 01:28:59AM +0100 schrieb Jason A. Donenfeld:
> Since rand_initialize() is run while interrupts are still off and
> nothing else is running, we don't need to repeatedly take and release
> the pool spinlock, especially in the RDSEED loop.
>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> Dominik - I'm still a bit unclear about early boot semantics that you
> seem to know well. Is this patch correct?
It seems to be.
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Thanks,
Dominik
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] random: do not take pool spinlock at boot
2022-02-12 0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
2022-02-13 6:55 ` Dominik Brodowski
@ 2022-02-21 5:34 ` Eric Biggers
1 sibling, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2022-02-21 5:34 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: linux, linux-kernel
On Sat, Feb 12, 2022 at 01:28:59AM +0100, Jason A. Donenfeld wrote:
> Since rand_initialize() is run while interrupts are still off and
> nothing else is running, we don't need to repeatedly take and release
> the pool spinlock, especially in the RDSEED loop.
>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> Dominik - I'm still a bit unclear about early boot semantics that you
> seem to know well. Is this patch correct?
>
> drivers/char/random.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index d4b692c9de68..8088348190e6 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -966,10 +966,10 @@ int __init rand_initialize(void)
> rv = random_get_entropy();
> arch_init = false;
> }
> - mix_pool_bytes(&rv, sizeof(rv));
> + _mix_pool_bytes(&rv, sizeof(rv));
> }
> - mix_pool_bytes(&now, sizeof(now));
> - mix_pool_bytes(utsname(), sizeof(*(utsname())));
> + _mix_pool_bytes(&now, sizeof(now));
> + _mix_pool_bytes(utsname(), sizeof(*(utsname())));
>
> extract_entropy(base_crng.key, sizeof(base_crng.key));
> ++base_crng.generation;
> --
> 2.35.0
Reviewed-by: Eric Biggers <ebiggers@google.com>
- Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-21 5:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12 0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
2022-02-13 6:55 ` Dominik Brodowski
2022-02-21 5:34 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).