Message ID | 20221013175148.335434415@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp405944wrs; Thu, 13 Oct 2022 10:59:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM499YVd/jVUQyQBAsE96n89eTm+Uan2nHa1BSdWCiS/bVGMyo3pSzGae4YDmcn/u0uFyy+k X-Received: by 2002:a05:6402:5cd:b0:446:5965:f4af with SMTP id n13-20020a05640205cd00b004465965f4afmr870955edx.12.1665683969118; Thu, 13 Oct 2022 10:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665683969; cv=none; d=google.com; s=arc-20160816; b=xV/BpdaVzx72ImMNWegV7QI+vvGrZUVHSnGvHAhB4TiEquRtkwKOcFiw5hPS/LH1wl 9qIZbNn4p8mW7JPOLMCXT1Xn1yJ13icuHGAYWoeDUS2D3KOKRnYIWQi5nZfIADVE5pED hxlaZXQg1tFI4+/KmgwWAygagSYg6WQjDHiaoSWbLCWnIHwuC7t1ktbEpuKMRL0kPkhF cwpkYTi0Xa0pkTWmLeMagKmKjgLmfi8BOUJWeK7cpPSoT07DnuoEre2ot6ROBlzi+Kw6 oWQaPLUJEV8KmgpQt9JRN3q40doeAhxm+Xs/DyXriW2BgKiEDOOen543G2vFo84wYEWx OBCw== 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=k/16nm3A0DR5YsWU+iqTx+1/OeviJvN/UUNOfoFyc9U=; b=pdViX9oM8aTyTEmFcVsmFIuNfiwp8rrLLvXtV79UMyC7p9vtvf3rftJIsN84I/M7Xa XHnTI/uIWw8qtJfRSqvgb13qHZjsIeBBqVWP43a6sQF54t6HffD9nux5v5t3htPIy4rM fsRy7QP6aXgHFiI4gi1lhwe9T1PqjtmoKSzhyUq3IMRfvkNo7Ld2k3gKN58k6m0L3UBI vDr0PT0W9hTJgNh5m1Ktctv5OahD+w7eOYvlgCycA7TjPZyKZDLJt2A8rGVJizsMVa5e noAcosA3gPJymyGqQ4rXodmrhoyQkpgHrSEr5eABqvmcclp/tfqxR5qJqKw+9D7DEWvB 7QBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JXwH/mBo"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170906304c00b00781e568f39bsi275058ejd.308.2022.10.13.10.58.51; Thu, 13 Oct 2022 10:59:29 -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="JXwH/mBo"; 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 S229624AbiJMR6Y (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 13:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbiJMR51 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 13:57:27 -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 380E8659EF; Thu, 13 Oct 2022 10:56:23 -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 18BB6B81CF4; Thu, 13 Oct 2022 17:56:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FF15C433D6; Thu, 13 Oct 2022 17:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683763; bh=NP1XPEhn7jtkvGePO/ii4tg8z2O0BgSRceDNFGGZJbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JXwH/mBoenPXO1zXVoUy4hPIxLn1+pEHD7viMJz/6opnDQaXqqYxHt2ZS/xOc4+5p shgUamLT44+1qZV/Pz9J/McBavNugFAb6SllJMQDX3PMXeqVwP0Oqh4tiJKjHLio72 I1+mTSNOdpnfKprSIRfG3qXxBY5iyqhNIos7CIl8= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, "Jason A. Donenfeld" <Jason@zx2c4.com> Subject: [PATCH 5.10 41/54] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:35 +0200 Message-Id: <20221013175148.335434415@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175147.337501757@linuxfoundation.org> References: <20221013175147.337501757@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596233898776299?= X-GMAIL-MSGID: =?utf-8?q?1746596233898776299?= |
Series |
None
|
|
Commit Message
Greg KH
Oct. 13, 2022, 5:52 p.m. UTC
From: Jason A. Donenfeld <Jason@zx2c4.com> commit 9ee0507e896b45af6d65408c77815800bce30008 upstream. In order to avoid reading and dirtying two cache lines on every IRQ, move the work_struct to the bottom of the fast_pool struct. add_ interrupt_randomness() always touches .pool and .count, which are currently split, because .mix pushes everything down. Instead, move .mix to the bottom, so that .pool and .count are always in the first cache line, since .mix is only accessed when the pool is full. Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -895,10 +895,10 @@ void __cold add_bootloader_randomness(co EXPORT_SYMBOL_GPL(add_bootloader_randomness); struct fast_pool { - struct work_struct mix; unsigned long pool[4]; unsigned long last; unsigned int count; + struct work_struct mix; }; static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = {