Message ID | 20221013175147.018941454@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 y7csp412275wrs; Thu, 13 Oct 2022 11:10:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7a6LPlnbuOwxPbXNhCV9bxXwh5ViX+btIUItbTXxU2qFnYIAt6WkwlHQTWYRgWI9f0pLaJ X-Received: by 2002:a17:902:ef89:b0:17f:8097:83bb with SMTP id iz9-20020a170902ef8900b0017f809783bbmr909089plb.20.1665684615610; Thu, 13 Oct 2022 11:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684615; cv=none; d=google.com; s=arc-20160816; b=X/VnME0ta/6g53hYYmSn16TyKYPyvvU+W64pMwS09zVZQqm6YIfWCuIqcheHegmWip aJouqZdbe/AGhT3ZUtXb49vPnL/JVOr6fuUvN69gKIXP7fm80AJ2HZJ3XZqVC1djk8hI Chs6YqDZvUc9OlZg8MDQWW10pXCfshpL755vI/Lc2QvTAX+C59KrtQecmLMEOPy0zhz6 RRkM/fh9WZ+7jMY7fVn//R+JQHxx020IHimzGCkQ9iVA1DA2loxjkFLJ4+OjXwmVnjBu +cbuyaVU4nxC9XNiCQyQZ0+CgWUkeFW0NS4PyJI2B3+9V+N5pNQJWdCFpHnr8AgqfeDU rVnA== 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=DmLpAb6c0BytwCX8H3bwk2/pfC4s0U+fzQfV7wsYv9I=; b=KWNTQEax5PHoPRNkj8Mi8VYJCV+F/34Whnsym+rIQR5uNNWIeE2XEcTGgfQvoEJNbg qO0qWARVVpbOdmNdQqkOKYCUNXE+bowxU4XSB7492z+3EXIvA3pcJf+o7dA92rQXWU42 sdGNZeFPj9/SeNHxHwoe1XLgBvwmx+sKyQOR+vEwc/Pt53O2D6mZy6SRP+I3nz95kp8Z w10apHIXkz64FhDOb6NyXe7/fEkzcUUMc8tbOW+3Yxy+D6lQ7QmvQOzODiMkgJGpRYIk WkOv9LeYbZRfxDwgp9qxvDygxFMmpBgrWQFcYlMxDGZ8k67bwktg4Q8LyNKgd0yxhvO5 H5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Qa1TQI3/"; 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 o5-20020a1709026b0500b00184c33ddeb8si446056plk.23.2022.10.13.11.10.02; Thu, 13 Oct 2022 11:10:15 -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="Qa1TQI3/"; 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 S231402AbiJMSJx (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 14:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbiJMSI5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 14:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE041633AD; Thu, 13 Oct 2022 11:06:53 -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 E493B6190D; Thu, 13 Oct 2022 18:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B6F7C433D6; Thu, 13 Oct 2022 18:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684081; bh=0AtYCypjBm2AxQIyd9GfbErbZ6yuOnswlF1Z4Pi9P8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qa1TQI3/FjCsTAyBQLaEBV5/j3r70zKPl4I/jqVzpGwO6uCzs+zVeT11iflJyk7qR +ngk+lziJeljf00aevZdchT6Anqt3+2xEHejuF8ucZcZAMQ+dIU+qx1660g5444HyH 3n7LqP0x6sc64YHrv+WHjJQmR3EH/eiWQoAxlkds= 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 6.0 19/34] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:57 +0200 Message-Id: <20221013175147.018941454@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@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?1746596911446184441?= X-GMAIL-MSGID: =?utf-8?q?1746596911446184441?= |
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 @@ -920,10 +920,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) = {