Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6158813iog; Thu, 23 Jun 2022 12:34:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uTPy12vvjE5cqVinCYPICgiUSGZqcUr2z5SEYfU9KQRniE4GwLcuQ/WPr5ujRnkRyP/o13 X-Received: by 2002:a17:90a:6fc5:b0:1ec:87db:b9f6 with SMTP id e63-20020a17090a6fc500b001ec87dbb9f6mr5721325pjk.104.1656012889286; Thu, 23 Jun 2022 12:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656012889; cv=none; d=google.com; s=arc-20160816; b=BfhSIMWZ8J7Cmw4anxZhPzZ6+vINCZggGH+FgPS+rWOaLDTpd1ED9JzWWWdIAUAOnL K+Nj8g3Dv1wj21Pw6KT9wNfrPacy95/Sh7qDjdR4Ogqd4hwNv5kuz97mWXjzUOg7ru+U cuFeT9/8QSDmBziiqloE7opQ3hPPYBhmP0DVgNrQUQtbucRwrN+G8lYOLvkdMfR2biUf aX0SHiNCTtCBC/15Pl3c2EvipUyIUtNOwRkS9Obi6OOpQ++HVSuNaTbWkpMC9rzaT96/ ePF6fQmLfr01nx/QwHrQz31GdYmDbAbBxQ7vWJRpeAjonQEoVT+kd148h4IK1DtZJCSa 36Cg== 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=jQYkv8NWte6K8UVuAZcDSj1V+ZQ3pc0E39/6IJPPMpg=; b=G/ruL09o5whsC/PNdjnfMvzyRWjfKrnH/Km2LZSS6s0weaU78Y3+vvMYlxT8fHVdnC 2m2tdW5p/TH4DK5otw1uzkKyAgJnHfnTJ2EmD5khFE2nCNKiAm48VKH42f8oqMpDZb4B tTIrQgqDRhfjgNerg8Vus/G+gx8Bp/7F6lcd1Dsz3WdWzNrd5qcCufWabhBXt1CBtKa7 k9Gqc5YBJ0tmSqUlFsj/eGx8ErdtNABd1l4VkAyKouU7/pj4M4/WzAdwT4CJRfVw2n+k dKt+e1+t4m8dqzRzoDRkx7mP6o7bObxBH/1GFOnAUlhVwkYZUcLxPc9yrcUT9uBd+LzS JNEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="G/N+7okE"; 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 b21-20020a170902d31500b0016a28448c46si386488plc.561.2022.06.23.12.34.37; Thu, 23 Jun 2022 12:34:49 -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="G/N+7okE"; 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 S231251AbiFWRJv (ORCPT + 99 others); Thu, 23 Jun 2022 13:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbiFWRHk (ORCPT ); Thu, 23 Jun 2022 13:07:40 -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 BFBDB527FD; Thu, 23 Jun 2022 09:56:25 -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 33A1060B20; Thu, 23 Jun 2022 16:56:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10678C3411B; Thu, 23 Jun 2022 16:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003384; bh=wuGc6sJSzUXA3aFYi5qj3h3c85UNYQTn645nLTMXJV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/N+7okEPPHKtHzYrzTGzttlVMQAB6oCzavLaywao535qV6KDHCCDWv/tDq+wlJOX Q6Ao4ZshDefwZ6ole3w4Nt2LuWxj0hs+4gm94NjSYbpVOnMvX4W9kcHACMgXKSu2ot obCwGi8Cr83DVTgviZx+rEC1a8TTrBc63gJzEBxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.9 214/264] Revert "random: use static branch for crng_ready()" Date: Thu, 23 Jun 2022 18:43:27 +0200 Message-Id: <20220623164350.128872269@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" This reverts upstream commit f5bda35fba615ace70a656d4700423fa6c9bebee from stable. It's not essential and will take some time during 5.19 to work out properly. Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -80,8 +80,7 @@ static enum { CRNG_EARLY = 1, /* At least POOL_EARLY_BITS collected */ CRNG_READY = 2 /* Fully initialized with POOL_READY_BITS collected */ } crng_init __read_mostly = CRNG_EMPTY; -static DEFINE_STATIC_KEY_FALSE(crng_is_ready); -#define crng_ready() (static_branch_likely(&crng_is_ready) || crng_init >= CRNG_READY) +#define crng_ready() (likely(crng_init >= CRNG_READY)) /* Various types of waiters for crng_init->CRNG_READY transition. */ static DECLARE_WAIT_QUEUE_HEAD(crng_init_wait); static struct fasync_struct *fasync; @@ -111,11 +110,6 @@ bool rng_is_initialized(void) } EXPORT_SYMBOL(rng_is_initialized); -static void __cold crng_set_ready(struct work_struct *work) -{ - static_branch_enable(&crng_is_ready); -} - /* Used by wait_for_random_bytes(), and considered an entropy collector, below. */ static void try_to_generate_entropy(void); @@ -269,7 +263,7 @@ static void crng_reseed(void) ++next_gen; WRITE_ONCE(base_crng.generation, next_gen); WRITE_ONCE(base_crng.birth, jiffies); - if (!static_branch_likely(&crng_is_ready)) + if (!crng_ready()) crng_init = CRNG_READY; spin_unlock_irqrestore(&base_crng.lock, flags); memzero_explicit(key, sizeof(key)); @@ -710,7 +704,6 @@ static void extract_entropy(void *buf, s static void __cold _credit_init_bits(size_t bits) { - static struct execute_work set_ready; unsigned int new, orig, add; unsigned long flags; @@ -726,7 +719,6 @@ static void __cold _credit_init_bits(siz if (orig < POOL_READY_BITS && new >= POOL_READY_BITS) { crng_reseed(); /* Sets crng_init to CRNG_READY under base_crng.lock. */ - execute_in_process_context(crng_set_ready, &set_ready); process_random_ready_list(); wake_up_interruptible(&crng_init_wait); kill_fasync(&fasync, SIGIO, POLL_IN);