From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5100FC433F5 for ; Thu, 30 Dec 2021 08:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237971AbhL3I7Q (ORCPT ); Thu, 30 Dec 2021 03:59:16 -0500 Received: from isilmar-4.linta.de ([136.243.71.142]:60846 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbhL3I7L (ORCPT ); Thu, 30 Dec 2021 03:59:11 -0500 X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES Received: from owl.dominikbrodowski.net (owl.brodo.linta [10.2.0.111]) by isilmar-4.linta.de (Postfix) with ESMTPSA id 2574320140C; Thu, 30 Dec 2021 08:59:10 +0000 (UTC) Received: by owl.dominikbrodowski.net (Postfix, from userid 1000) id 6720C8067E; Thu, 30 Dec 2021 09:59:05 +0100 (CET) Date: Thu, 30 Dec 2021 09:59:05 +0100 From: Dominik Brodowski To: "Jason A . Donenfeld" Cc: linux-kernel@vger.kernel.org, Theodore Ts'o , "Ivan T . Ivanov" , Ard Biesheuvel , linux-efi@vger.kernel.org Subject: [PATCH v8.1 7/7] random: move NUMA-related code to CONFIG_NUMA section Message-ID: References: <20211228153826.448805-1-Jason@zx2c4.com> <20211229211009.108091-1-linux@dominikbrodowski.net> <20211229211009.108091-7-linux@dominikbrodowski.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211229211009.108091-7-linux@dominikbrodowski.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Dominik Brodowski --- 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;