Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6031317iog; Thu, 23 Jun 2022 09:56:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tv/Cr7gM9i+MnJSXt0r476WhJ7FQ+fKQzGKZjXKQ+te5c92NIHOR1hZ32FTpWfJ1j0xpvX X-Received: by 2002:a17:907:8c05:b0:726:2a09:c951 with SMTP id ta5-20020a1709078c0500b007262a09c951mr2834611ejc.143.1656003381008; Thu, 23 Jun 2022 09:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656003381; cv=none; d=google.com; s=arc-20160816; b=To7lEla99b9K7sn5uauHdrgjBWpRTOkS14hoozYxPrlBtnxgV9SBIXKR4Z3Fln/v/y 3VcsfkKRmqj4ocu+QtfQMypmCGfPpMo0np75cUDwdDCnHK3fkhfWEANBqG+0zokRu7be hDd/DSjhJ04Hom0SCeftGr3+3i5/xU+QzW2LWShB9VWo6Un4iuNqQrFOsTSUhxOs/F8p xtVMuL7iwBxDem0WkAeGZCv5J537CLd1c5H9wYifFbDrdtX70NOlsSBOlUMx8ck3z948 n+LDSnz2tei3ynGbzrxLtV8Uam/zwpuuPDhfL+Um9h6CGDeXVmaBf17c9HjztXQJDHrN Vd6w== 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=gL9h1Juw5Hj5Qi+YtawrGdUIAimqx6N9B0F4g2IZcgk=; b=xCndf1Jc15tUUmHasNyGJZDvLMfbxVMrHaM8mRN1+sa7hwL87yv8jzsRprxqtC2TQP NUhRZu4zY2sjuLmetwjisl/9EUQXkOrTowOQJNmn+/YfY/KcVazadCM38+TtAVVpKOYs OOxnyd2p+RglknCX8LLgWlLBPW6FeWwxJSfdZCTSuMr08ak01r3YSJ3Pj5AtVNa8u8Pl E8DVvwjYURS2csCUwf7Ua4Rv7z7+RwQZvNA2crybuM3QTVGIqMCoJqCP+mqs6rY9ZahX ekGUTUCbRVvUeVSQxip9hEd5kCDkxokd1KAuaNavypOAihRD4nI2NHjFwtl5ao52a0OA LM/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xvycc3zl; 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 eb11-20020a0564020d0b00b0042a9fccd3f2si89800edb.353.2022.06.23.09.55.54; Thu, 23 Jun 2022 09:56:20 -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=Xvycc3zl; 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 S232304AbiFWQxG (ORCPT + 99 others); Thu, 23 Jun 2022 12:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233907AbiFWQvv (ORCPT ); Thu, 23 Jun 2022 12:51:51 -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 BEC4821800; Thu, 23 Jun 2022 09:51:38 -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 574F161F90; Thu, 23 Jun 2022 16:51:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 237EBC3411B; Thu, 23 Jun 2022 16:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003097; bh=qDiaCc4FHNBqJDJ8zGZcdPoTAJhHp92c2LQwYafhUYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xvycc3zleX3xevBguV3YFVd7xgBiVKoxvF448S6HKVYqtacPjn7ay9NwJ9W1rR/Hw Q285plwJBeRFGqFReVXh58WYc0SN7H613DH/EXqdNjj/pKzIkYF4TGMo1oCiSGGO3P xmpTIX4xx56r8+aG3STmXlNhc7B7x7f96roZafag= 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 4.9 088/264] random: use IS_ENABLED(CONFIG_NUMA) instead of ifdefs Date: Thu, 23 Jun 2022 18:41:21 +0200 Message-Id: <20220623164346.561810956@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@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 @@ -762,7 +762,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 @@ -770,7 +769,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); @@ -817,7 +815,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); @@ -868,7 +866,6 @@ static void crng_finalize_init(struct cr } } -#ifdef CONFIG_NUMA static void do_numa_crng_init(struct work_struct *work) { int i; @@ -895,29 +892,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