Message ID | 20221013175145.887818528@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 y7csp410300wrs; Thu, 13 Oct 2022 11:06:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5rza7eLsZ6GGhwF20k2ZwSShG3dzRcqG4Ky32AWDQFKHjsluWHPrJ/MBgfHxLqEuLuMLku X-Received: by 2002:a17:90a:fd01:b0:20b:61f:cd49 with SMTP id cv1-20020a17090afd0100b0020b061fcd49mr1089297pjb.239.1665684379053; Thu, 13 Oct 2022 11:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684379; cv=none; d=google.com; s=arc-20160816; b=a3PCmpzpS4kxHadYJ8rV8L/o8CK18e3KCG1twoqfUcO09heBk97UBBF7M7DjU45Xsb 9YV2d3Xt6V2q3M2yRtr2fR1WvXmpKxI4ujpPjcF3sZiT1YI3ZjFRKadG8H7z9rIXq4iT rck90ZWFD5a+yKWQsF0Vsg0LpbOKyGwMCUCU42thbUz3RPx+NS+ZonuadM3re2cxAS1w 4Rr4CWmko7ncuWHWJSB3cegWu03/a2sVFkvCvUa/BkatnxsvTtFtzSJXT5nd8gD3yYtg +Wiv7+WR0Cp0UqKz96F2yy+U1WwCuZgehLBa50x0nWSRLUjDtmPCGfLHNbuq587HQYTo cBHA== 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=/6F5mlTqlECeS8KfR8QpT/t8n9/7qCHPSWh2xV3aoWY=; b=R5q18/EI3S6D7xJAzwJynKMJaE9Tl+DqrqPupi2AsESerNtDUN6PZFIm+tdhPrcZRw dzsqq2kbnRBMCzpwgpmQmhNu/CtnGPO6PvrDd8rok0JW5odCY6N+odm5iZPtycoGW9RN qokjtf/1qaSJBruX5CARgB8IasyirZuxjDH58gMsKFDqyKHciDMt3znUpZQPoTTDy4Si yOE6w1bHMp5x6hBBcn7lNvBw3CVKEH7jS27W+wjfrzB4Wh2xaSPDbPH7TKdMNMyFW076 z5xIbvAiV62NuuKTQbQvAOGqQtzFVPons4Hn0Y9WDrjtIL0q6EC12EMsNuE5kyCC+w3s 6K6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1eiYyJPo; 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 k21-20020aa788d5000000b005636ce48882si96411pff.45.2022.10.13.11.06.06; Thu, 13 Oct 2022 11:06:19 -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=1eiYyJPo; 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 S231299AbiJMSFr (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 14:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbiJMSDj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 14:03:39 -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 D303A157F5F; Thu, 13 Oct 2022 11:03: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4375461952; Thu, 13 Oct 2022 18:00:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4941FC43143; Thu, 13 Oct 2022 18:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684023; bh=wWxXNLldQJWjVR9cUWjf0UKYSuekCHsercakn8tOViM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1eiYyJPoKshujY3RDf7cXo4GmJfJ//cnAvgJzt8StnPv3FyQ16sJIwwnHDtztK9eZ 3rgECIoaD6vidM7Azg0j9umeiMz5UJANTzlFg+qmlapPzprI0+kgkEBpSuMaL6/VqT tKOzBsleYnlXi61Qq/GEYkaYlXyXWTa7IUdvkQ2U= 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.19 18/33] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:50 +0200 Message-Id: <20221013175145.887818528@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175145.236739253@linuxfoundation.org> References: <20221013175145.236739253@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?1746596663316455069?= X-GMAIL-MSGID: =?utf-8?q?1746596663316455069?= |
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 @@ -903,10 +903,10 @@ EXPORT_SYMBOL_GPL(unregister_random_vmfo #endif 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) = {