Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2901067iog; Mon, 27 Jun 2022 05:23:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPdqy+4P7bXFm6S7Q+iOxfK4mJ7NnrDrbu0iHc2oGCVoGNa7sfv8bGT553BPgMer6ByZ7S X-Received: by 2002:a05:6402:280b:b0:437:9efc:a065 with SMTP id h11-20020a056402280b00b004379efca065mr2876666ede.3.1656332635961; Mon, 27 Jun 2022 05:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332635; cv=none; d=google.com; s=arc-20160816; b=CAV8F3J9wwt34KnHs6k2a4AfUqqjLK4vGE4J2PFZVq8ZH4ydxYbiAdduhNXgEIKBkw WAXw9+5awEfpkURTidZTpykzKuMPoTTX3wbbSWuRgmOy8QXBqRSS3takL/Aozg/s48dX QGKd5M8q74AERTNQDBHVBs+0oOa2l4ubY7SKCZgyFS8lGqTQ19x5EA+9HREaMwp22KC7 nzk0IxTZpBcmzDaibCxfGW3bSKA5+Mvd9CUZ6X5XaPj29oeItlxxX8WB/akIBRfAKvmX LZXxm/ruy4xkBaAkJg9VX6jv394NJPDKL2IiS5e1yvuy7AAzZytCMeW8l7/DPcwrSCVN IQIg== 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=+2kKAwjmS55sYR/BE7LRkw24d3c/wA3uAbPTZkGgd88=; b=PsVzaVCBpABWJzbOAIs+4fSlM9XqAK+OlWPCXrtPX0PpMO2oSeXvJpO57clZJPT9od e5EfmnH7HQV5qwVJNpiJDJ+dAYPSULF4vKTM3/C+hlRHx/xEaFPQ0bnamImqaf9pWR90 lIAUte4dkBnW6vPkg1zWL5NibUKyJ9bcV9JqIvbBRm4ZlnzyYEZuug2lHDaqZSoPsVmh lAa29FjGUghivbMxt5NvBI0rggKmusgyx8jN2eZhy2pgpYjksIGCjGQDSxgfV88U4Vmm Jeczldlvf8CC4SS/k822kgME9kbDKA9ZMYJTe+XnRKoT46n6KqE3yWFqMCAS4m0w6jHj dvMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jnPJ56+l; 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 e17-20020a056402149100b0042ad3f6ffddsi12063362edv.47.2022.06.27.05.23.32; Mon, 27 Jun 2022 05:23:55 -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=jnPJ56+l; 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 S236122AbiF0Lfi (ORCPT + 99 others); Mon, 27 Jun 2022 07:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236107AbiF0LdP (ORCPT ); Mon, 27 Jun 2022 07:33:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17DB2E8; Mon, 27 Jun 2022 04:30:18 -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 4F3736141D; Mon, 27 Jun 2022 11:30:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E169C3411D; Mon, 27 Jun 2022 11:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329417; bh=h1N85u9a3APp1yw2woC9p/8mzkK2TLZrhyjIps8M9WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnPJ56+lRcbQMruB9fIppf44L3pUT9XKE2xITQRDtAyB6lmZUTXGB5gbIoHKzInpK +3BEsPryJR3Pe8l+SHJlboiALY94r8QE6IFOJ63vP4uKg+WMDCkjnakJPth9COqYSg vFBJuSVNqXP7pFEGiFv4HBImae3DofY8dlULgPZs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , Sebastian Andrzej Siewior , "Jason A. Donenfeld" Subject: [PATCH 5.4 02/60] random: schedule mix_interrupt_randomness() less often Date: Mon, 27 Jun 2022 13:21:13 +0200 Message-Id: <20220627111927.719224755@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@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.5 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 534d2eaf1970274150596fdd2bf552721e65d6b2 upstream. It used to be that mix_interrupt_randomness() would credit 1 bit each time it ran, and so add_interrupt_randomness() would schedule mix() to run every 64 interrupts, a fairly arbitrary number, but nonetheless considered to be a decent enough conservative estimate. Since e3e33fc2ea7f ("random: do not use input pool from hard IRQs"), mix() is now able to credit multiple bits, depending on the number of calls to add(). This was done for reasons separate from this commit, but it has the nice side effect of enabling this patch to schedule mix() less often. Currently the rules are: a) Credit 1 bit for every 64 calls to add(). b) Schedule mix() once a second that add() is called. c) Schedule mix() once every 64 calls to add(). Rules (a) and (c) no longer need to be coupled. It's still important to have _some_ value in (c), so that we don't "over-saturate" the fast pool, but the once per second we get from rule (b) is a plenty enough baseline. So, by increasing the 64 in rule (c) to something larger, we avoid calling queue_work_on() as frequently during irq storms. This commit changes that 64 in rule (c) to be 1024, which means we schedule mix() 16 times less often. And it does *not* need to change the 64 in rule (a). Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Cc: stable@vger.kernel.org Cc: Dominik Brodowski Acked-by: Sebastian Andrzej Siewior Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -996,7 +996,7 @@ void add_interrupt_randomness(int irq) if (new_count & MIX_INFLIGHT) return; - if (new_count < 64 && !time_is_before_jiffies(fast_pool->last + HZ)) + if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ)) return; if (unlikely(!fast_pool->mix.func))