public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: "Jason A . Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
	"Ivan T . Ivanov" <iivanov@suse.de>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-efi@vger.kernel.org
Subject: [PATCH v8.1 7/7] random: move NUMA-related code to CONFIG_NUMA section
Date: Thu, 30 Dec 2021 09:59:05 +0100	[thread overview]
Message-ID: <Yc102b3gCiIjC88e@owl.dominikbrodowski.net> (raw)
In-Reply-To: <20211229211009.108091-7-linux@dominikbrodowski.net>

By moving crng_initialize_secondary() and crng_init_try_arch() a few
lines lower to the CONFIG_NUMA ifdef section, we can remove the
__maybe_unused attribute from the first function, and reduce the
footprint for !CONFIG_NUMA.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 drivers/char/random.c |   52 +++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

v8->v8.1:
crng_init_try_arch() isn't used elsewhere, therefore it needed to be
moved to CONFIG_NUMA as well.

diff --git a/drivers/char/random.c b/drivers/char/random.c
index a5bf662578cb..181b61104948 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -783,24 +783,6 @@ static int __init parse_trust_cpu(char *arg)
 }
 early_param("random.trust_cpu", parse_trust_cpu);
 
-static bool crng_init_try_arch(struct crng_state *crng)
-{
-	int		i;
-	bool		arch_init = true;
-	unsigned long	rv;
-
-	for (i = 4; i < 16; i++) {
-		if (!arch_get_random_seed_long(&rv) &&
-		    !arch_get_random_long(&rv)) {
-			rv = random_get_entropy();
-			arch_init = false;
-		}
-		crng->state[i] ^= rv;
-	}
-
-	return arch_init;
-}
-
 static bool __init crng_init_try_arch_early(struct crng_state *crng)
 {
 	int		i;
@@ -819,14 +801,6 @@ static bool __init crng_init_try_arch_early(struct crng_state *crng)
 	return arch_init;
 }
 
-static void __maybe_unused crng_initialize_secondary(struct crng_state *crng)
-{
-	chacha_init_consts(crng->state);
-	_get_random_bytes(&crng->state[4], sizeof(__u32) * 12);
-	crng_init_try_arch(crng);
-	crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
-}
-
 static void __init crng_initialize_primary(void)
 {
 	struct crng_state *crng = &primary_crng;
@@ -871,6 +845,32 @@ static void crng_finalize_init(struct crng_state *crng)
 }
 
 #ifdef CONFIG_NUMA
+static bool crng_init_try_arch(struct crng_state *crng)
+{
+	int		i;
+	bool		arch_init = true;
+	unsigned long	rv;
+
+	for (i = 4; i < 16; i++) {
+		if (!arch_get_random_seed_long(&rv) &&
+		    !arch_get_random_long(&rv)) {
+			rv = random_get_entropy();
+			arch_init = false;
+		}
+		crng->state[i] ^= rv;
+	}
+
+	return arch_init;
+}
+
+static void crng_initialize_secondary(struct crng_state *crng)
+{
+	chacha_init_consts(crng->state);
+	_get_random_bytes(&crng->state[4], sizeof(__u32) * 12);
+	crng_init_try_arch(crng);
+	crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
+}
+
 static void do_numa_crng_init(struct work_struct *work)
 {
 	int i;

  reply	other threads:[~2021-12-30  8:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 19:04 [PATCH v6] random: fix crash on multiple early calls to add_bootloader_randomness() Dominik Brodowski
2021-12-28 14:06 ` Jason A. Donenfeld
2021-12-28 15:38   ` [PATCH v7 1/4] " Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 2/4] random: do not re-init if crng_reseed completes before primary init Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 3/4] random: do not throw away excess input to crng_fast_load Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 4/4] random: mix bootloader randomness into pool Jason A. Donenfeld
2021-12-29 21:10     ` [PATCH v8 1/7] random: fix crash on multiple early calls to add_bootloader_randomness() Dominik Brodowski
2021-12-29 21:10       ` [PATCH v8 2/7] random: do not re-init if crng_reseed completes before primary init Dominik Brodowski
2021-12-30 14:31         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 3/7] random: do not throw away excess input to crng_fast_load Dominik Brodowski
2021-12-30 14:32         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 4/7] random: mix bootloader randomness into pool Dominik Brodowski
2021-12-30 14:33         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 5/7] random: harmonize "crng init done" messages Dominik Brodowski
2021-12-30 14:34         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 6/7] random: early initialization of ChaCha constants Dominik Brodowski
2021-12-30 14:40         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 7/7] random: move crng_initialize_secondary to CONFIG_NUMA section Dominik Brodowski
2021-12-30  8:59         ` Dominik Brodowski [this message]
2021-12-30 15:12           ` [PATCH v8.1 7/7] random: move NUMA-related code " Jason A. Donenfeld
2021-12-30 14:31       ` [PATCH v8 1/7] random: fix crash on multiple early calls to add_bootloader_randomness() Jason A. Donenfeld

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=Yc102b3gCiIjC88e@owl.dominikbrodowski.net \
    --to=linux@dominikbrodowski.net \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=iivanov@suse.de \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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