Message ID | 20221013175145.189973572@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 y7csp404459wrs; Thu, 13 Oct 2022 10:55:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Etucey+GjiKt1VHLYwem4/rr3ijHzjxA+nIkhCAJb38PC9uyeY5Hoycvv27kt9kq1iGXE X-Received: by 2002:a65:6bc4:0:b0:439:8ff8:e2e1 with SMTP id e4-20020a656bc4000000b004398ff8e2e1mr917581pgw.91.1665683707927; Thu, 13 Oct 2022 10:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665683707; cv=none; d=google.com; s=arc-20160816; b=clUIpniLQUxKqw2D4WWzsqVwWBn2TUKAbBykuTtcj9eycUsfg/+d8grEBvhtOprPAC 10P7bH+EMp10g9+mPC46407PBt8jJjiu8e0b8lgq4BdMgnutAJbTO7IJ7OH4xjPhNRih 5BIkgh5XAwLpbUehAJaadvAXc/jW9KMqJjsg8A6GApCX8UTUZ9xjnE4AnwXEdXIs1B7o lonNhp3B0J4MkcRsoAdXBNaCfzZsH6GCeQ/hb2L8HMulIvJZ2a8QFx0vYjbH6j53Opif BvZMQNeOrFN4pgFsVdnqXsubQ6aXoeW53Ss4j7DB7oLM+nI5bi8nIyzsm7ERawuWVNLR xbhg== 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=WIR2DLtrEX0dj9NkuFSYbj1Dtbakne4q5wM7kqmAms0=; b=dDzY8ExEBx2kEwtQTNrNd9mNfWzTRM29uE/nB9Ko0XdXHYAKwEht65MJ89M9Eq22ot A6M0i0wB6ZVVXCf817JsvmNmFhso2AYDqAWGe1LrUnhFONPbpP5u8wmfsZ8AS3mUlgtm 8BzoFpxDQEXocMAycLBs0yCjFBHR5+ai8LR0J19a36q7Pt2OgCSyBqsB69OAtYxJlEa7 5fp8sIAHl61vyTUG9Fu4pu6AOi+bGe76Nm0tRzHFxLkqMDX/Fz9bJGYsaCp7M+O8zO/e HwumZX/84F1dY/ojPQhdVnKFbsL63zIdn822F9Fqz7CEnbDoeS1ozOUbA//1ssXS8NO9 73cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LYpzQvrH; 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 e187-20020a6369c4000000b004582242c80csi20458519pgc.801.2022.10.13.10.54.56; Thu, 13 Oct 2022 10:55:07 -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=LYpzQvrH; 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 S229906AbiJMRyc (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 13:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbiJMRxx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 13:53:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FBDD1578A5; Thu, 13 Oct 2022 10:53:37 -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 B8364B8202A; Thu, 13 Oct 2022 17:53:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18306C433D6; Thu, 13 Oct 2022 17:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683613; bh=HvNQLbDFpQyKb6hj8OG6baMZ1QDProYxanDCjhbgJvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYpzQvrHqKKswL1ykGZbffQ/vLIZRRRQrBwgzn52fw0E8sqzGWDLPwQinKYo7eRNO YBiMMUf4rNTYit62e7Alrv91POQOq4UIlYd/ItUHhQSsrT4m+JcwCMXmRYgIKPdgRV FDGiLBW2NpuGhGOpHwGJft9Z610RsvezVxS+P86M= 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.4 28/38] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:29 +0200 Message-Id: <20221013175145.189973572@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175144.245431424@linuxfoundation.org> References: <20221013175144.245431424@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?1746595960055510554?= X-GMAIL-MSGID: =?utf-8?q?1746595960055510554?= |
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 @@ -890,10 +890,10 @@ void __init add_bootloader_randomness(co } 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) = {