Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2204741iof; Tue, 7 Jun 2022 23:08:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK//r1piyAy2V3FYLk/PBS1nRd3R/iXflzDt8KCFKgWLhOZKP3QofpGtGn6rrSY7XVwK3R X-Received: by 2002:a17:90a:1d1:b0:1dd:220a:c433 with SMTP id 17-20020a17090a01d100b001dd220ac433mr36678990pjd.196.1654668529919; Tue, 07 Jun 2022 23:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668529; cv=none; d=google.com; s=arc-20160816; b=qOjdrVxfvcdNE0kdocj8co1EQyO22RSOcWKgTfXzYWd+ts8AAeH0jU6PAkoF6UxIXe dONFp0MxrKxPfVCCOmoH2gbh1fp+a66k7+SovOj48aYT4RzxKcBxqtd8GqBkbMjKPakL 2uvIxe/P0qymlRnXTfG8XwoA/2s5X/Xo0QOiNUJjMuzNRbeMhANCZdPtf/IOo9/CWZ8E 2vmN+M3KXVL3/cumchCHca1/9U6Ur43PMVpesVFvcSOeu7a8O6Zp8+ZoMn+1cjMoBVNx DXmkNNf8JrUDkOmx64SC+ofbLtHkZ2xQMiDnOMt558iEpJmn8qweU8ScBdufOvIPI3Pw yHJw== 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=yyD4dInSrDJLp/4KlZZUrT6277fhfruY5piIHKsEJoQ=; b=C16MeDnZMJUeD//5Hxbs/H0O2kP5IGKUDtzNKYVr1XN0BAJlEuYAYCzpSltruoANeZ Gbhdr/MxSXoeGLDGNTco8Ju0+Wfef20zP4YCyjnj+kH3ydjRujeOP1KrTqVmikBvI9yf 2qCkq80o2fwwT/65z4A9WHvTKRQRj9BNAEdnOEVq/CA926Mgn+tt8ZFn9onQQ8W2AsFE QgkMPvciDw6njANWc35tVEQKJfI1B6uUlsZTFVW+7/KrVtQXo6PIj/mSBtPJZxdO1/Jc sm045L8SJ09PPjslfwjbkQNYwyPNaXWTXrCnbkV6Sh6FLGjaLPp4LxQbl5VMotOR7L9I Myhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyC1SywN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m185-20020a633fc2000000b003fa0ae4f59fsi26570797pga.52.2022.06.07.23.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyC1SywN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22385E205F; Tue, 7 Jun 2022 22:31:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386093AbiFHBgc (ORCPT + 99 others); Tue, 7 Jun 2022 21:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381781AbiFGWcc (ORCPT ); Tue, 7 Jun 2022 18:32:32 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA4B22508; Tue, 7 Jun 2022 12:25: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 sin.source.kernel.org (Postfix) with ESMTPS id 5B9C2CE2478; Tue, 7 Jun 2022 19:25:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43FB3C385A2; Tue, 7 Jun 2022 19:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629921; bh=4EKyYJ2EBnd47zcCCrMDKfdZTmj/kYWTH+AI9gJfgTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyC1SywNpxZ69SVJoNZIKdP53G5ImWEzNJUfyKq7Ccg2O436HjZ86KcA+nRnIXIF4 h8ipvEzum8hGcPdCtqPdZFpLw2PlgrGU8Tpm9El5qWFDfD7LIW5jdIKXbx9qaKV3uv zH3AqyBK9vX6FIBpNaMPsHaZsLTSMGL9/3vtTivI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.18 866/879] Revert "random: use static branch for crng_ready()" Date: Tue, 7 Jun 2022 19:06:24 +0200 Message-Id: <20220607165027.989427675@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 --- drivers/char/random.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -78,8 +78,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; @@ -109,11 +108,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); @@ -267,7 +261,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);