Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2941856iog; Mon, 20 Jun 2022 07:58:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6ZbTZspt8J4KVhu8Oc+HWZsyVPSLfLF8Tr+7N5pfPnmxkgq09VnI4i4PqB/aniCFFtheI X-Received: by 2002:a17:90b:341:b0:1e0:cf43:df4f with SMTP id fh1-20020a17090b034100b001e0cf43df4fmr27641241pjb.126.1655737103552; Mon, 20 Jun 2022 07:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655737103; cv=none; d=google.com; s=arc-20160816; b=SqZqbtCAcJHXwKtQKEsnQBd94A5T5PIvHZiqKgJWlPlf/qoCUTw6HuKRM8KJePHtRe /zS0Xq0TdRt60iRCPPHU9sZzesjXRpelg5B/tG92XOPhLo+O9ZykgJH4eAxRf3H2+w2i f2sYilyZwML+rG2USdQGi95se8HUyisIDUeoLnFqYD7Ru+YWtoE80T/quA+wzrBhhK90 04aBN3XIAlBT7ixQnGFl0z/9yxIag4BmQqAvlH0tL+ALTsuh8HOaCPLJapsJ5CAfJ8ZY O29RaQqrTeN1ebhFqSNMbi3Wb8qLbCFvoA8vtJYNi+pUrq80Ko5uLPMTf44pJeL1/WYe N77A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hoNZVnla+BOhVkCwR/yao9escTWulr9cj2rP5w21yk4=; b=NFOM/18ryxBph9UEmV4kIC/7pOqsM1x40VV5xtCjAlNNRn81xDF7TzndGzCc2fd2i8 cfXIBFxX3ubdCQlwQQ1MwknlNikX8odlwGh4hIKGlTFERtLBevvFXniyG5Nhz5tY5QVN k5wFQp2AfErU1JwM0k20PyebEa8ka2vepPa204DVzM1QP2HIqvW5RA1PYQHY2wHtL1kQ lZ/2hfzz49sP0BZdrtZHmJ/n0nZfxhr+63zrSUix/SF+jO5PbyRicJNv8YOH+qu3lci+ gvUWHH6icFnrSksSIXX/fqFZ2PnT7Loq5wVhe0GWjFWfZKn83qEskpb5jJemiBjph5Fs sK3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="OuyRd5/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a63f947000000b003db379692e2si9950498pgk.181.2022.06.20.07.58.10; Mon, 20 Jun 2022 07:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="OuyRd5/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349591AbiFTNwF (ORCPT + 99 others); Mon, 20 Jun 2022 09:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350844AbiFTNt4 (ORCPT ); Mon, 20 Jun 2022 09:49:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B55530F49; Mon, 20 Jun 2022 06:18:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 630B660AC0; Mon, 20 Jun 2022 13:12:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C7AEC3411B; Mon, 20 Jun 2022 13:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730749; bh=i3hMr2zvbLMfhNtdbaivhSFl4gNmB97jXjyHRJ9vF78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuyRd5/J2meuuyILZQZdRzUcynzoTfu0kpFhzoa14Yn2WzMWrt95QkzuDB3C+E6HO 8NEqkDEqn+IR0JvAWlR/4l2SxIvlq0NKRBFRbb5exFH+Fd6DTLbfrapwnobRVlmqd5 EoyFVdYmzcxd29D4pG3ebCuqbAUWvzMoGvXTOYGA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 5.4 044/240] random: use IS_ENABLED(CONFIG_NUMA) instead of ifdefs Date: Mon, 20 Jun 2022 14:49:05 +0200 Message-Id: <20220620124739.317913384@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Jason A. Donenfeld" commit 7b87324112df2e1f9b395217361626362dcfb9fb upstream. Rather than an awkward combination of ifdefs and __maybe_unused, we can ensure more source gets parsed, regardless of the configuration, by using IS_ENABLED for the CONFIG_NUMA conditional code. This makes things cleaner and easier to follow. I've confirmed that on !CONFIG_NUMA, we don't wind up with excess code by accident; the generated object file is the same. Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -760,7 +760,6 @@ static int credit_entropy_bits_safe(stru static DECLARE_WAIT_QUEUE_HEAD(crng_init_wait); -#ifdef CONFIG_NUMA /* * Hack to deal with crazy userspace progams when they are all trying * to access /dev/urandom in parallel. The programs are almost @@ -768,7 +767,6 @@ static DECLARE_WAIT_QUEUE_HEAD(crng_init * their brain damage. */ static struct crng_state **crng_node_pool __read_mostly; -#endif static void invalidate_batched_entropy(void); static void numa_crng_init(void); @@ -816,7 +814,7 @@ static bool __init crng_init_try_arch_ea return arch_init; } -static void __maybe_unused crng_initialize_secondary(struct crng_state *crng) +static void crng_initialize_secondary(struct crng_state *crng) { memcpy(&crng->state[0], "expand 32-byte k", 16); _get_random_bytes(&crng->state[4], sizeof(__u32) * 12); @@ -867,7 +865,6 @@ static void crng_finalize_init(struct cr } } -#ifdef CONFIG_NUMA static void do_numa_crng_init(struct work_struct *work) { int i; @@ -894,29 +891,24 @@ static DECLARE_WORK(numa_crng_init_work, static void numa_crng_init(void) { - schedule_work(&numa_crng_init_work); + if (IS_ENABLED(CONFIG_NUMA)) + schedule_work(&numa_crng_init_work); } static struct crng_state *select_crng(void) { - struct crng_state **pool; - int nid = numa_node_id(); - - /* pairs with cmpxchg_release() in do_numa_crng_init() */ - pool = READ_ONCE(crng_node_pool); - if (pool && pool[nid]) - return pool[nid]; - - return &primary_crng; -} -#else -static void numa_crng_init(void) {} + if (IS_ENABLED(CONFIG_NUMA)) { + struct crng_state **pool; + int nid = numa_node_id(); + + /* pairs with cmpxchg_release() in do_numa_crng_init() */ + pool = READ_ONCE(crng_node_pool); + if (pool && pool[nid]) + return pool[nid]; + } -static struct crng_state *select_crng(void) -{ return &primary_crng; } -#endif /* * crng_fast_load() can be called by code in the interrupt service