Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2908246iog; Mon, 27 Jun 2022 05:33:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tihA6evEvTeYlfbIzqmq+2jDf4CbnM9EvmC2Y2MLwcqna49yCt42YN0qK4zkLxWC5kQpa/ X-Received: by 2002:a17:902:d2d1:b0:16a:1dd9:4d3d with SMTP id n17-20020a170902d2d100b0016a1dd94d3dmr14292441plc.18.1656333183441; Mon, 27 Jun 2022 05:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333183; cv=none; d=google.com; s=arc-20160816; b=onGSEN2mHl0j+Ja1bADCM24+/AIWwSkjeOeVPDW1Gfh+QdzbYAJa+BVW8NQg09dTrS 0vFUmLpIcGk0+jG1bw2LJMIgpeoj3Ksc5fVmHyvKKKetl18c3KkwOgxeshhVAJI9rhS5 StGjykEjdi/ZAX+JTuvozOapcZg3L1T6CB6zc+hompyFnzYvzQ5swjlXbqbdS07g5Li/ QqqzVjvKuumkLnmKNyXQtttFSMmxFl3qs/rFadPU5ouLXJ+ru64aFSGzLdeNHM8WjKJ/ QC+1auFRjXOwcLx/S837mkOIZA/T3+bV8HQGR9/D3vBrpKTHWNVaSOc3tvhpV6oShabe BNAw== 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=QJwRY7GXctJa964UUWaUDTM1wUWopWGdW0A9BDtSNFQ=; b=wePVDLACTW+2YhcVzotqK4VnmyRLiMID5HoSbm0S7qbC5v6AjMiafWdNYsSza0oMlG IO9uVyoycpKB5Ewa+zwsasnK+0L/dD7MPJNwth6QfEfPChsQKef+r1D7K4VX1W0Dz99E Gn998WgnYXKoZnZ8tjuXGEIEajSYFAqep7P7b4GDqMQ9cS9g5WJNz9lSPgPiTY1QRje/ py5uoRqkQiSgDz4FJK+fVw6Si265PLjKnN8S4Z1bmkGoq/UNrSyiFYdsF47geEIH4OMD CMeMPjCMsNpKxcaY+/lLS+ayLszdE+i4by6Nv+n0DhwJJydmUCT6qzf1JtACOciA+zK1 v3UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YebQubZy; 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 m19-20020a056a00081300b00525626fe8c0si17084458pfk.365.2022.06.27.05.32.50; Mon, 27 Jun 2022 05:33:03 -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=YebQubZy; 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 S237657AbiF0LrG (ORCPT + 99 others); Mon, 27 Jun 2022 07:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237437AbiF0Lmv (ORCPT ); Mon, 27 Jun 2022 07:42:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 192CF1BE; Mon, 27 Jun 2022 04:37:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id C3A6BB8111B; Mon, 27 Jun 2022 11:37:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E67DC341C7; Mon, 27 Jun 2022 11:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329874; bh=zckJ25KeNwOmmOgkYtdLY02GYh+uT/iHtBb4i7YgXj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YebQubZy0IYFCyJWtBr3QrIcdcfxQgwt+Gp+Zv0+G+ppBXkPQ+LaQVnOX36mnwQ0X VE7tNBNfYIMGdYHHaOvmJYZYDbFDs7zHszL2mawcZZ7kTNwpFLYh43AG7CC49yr/id AHpBwz5cHAEmWqJYdue9G+AwqienuhSzuMADOLQ4= 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.18 001/181] random: schedule mix_interrupt_randomness() less often Date: Mon, 27 Jun 2022 13:19:34 +0200 Message-Id: <20220627111944.599548853@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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 @@ -1038,7 +1038,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))