Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1448992iob; Thu, 5 May 2022 01:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1fKme7V549pFjdhzb/A3OMYMmTTRXNBp+VOT3fJIfC4eZtq0Ab8gNGsMj4EAHq+sGWHBe X-Received: by 2002:a17:902:ecc2:b0:15e:9add:104c with SMTP id a2-20020a170902ecc200b0015e9add104cmr22144375plh.140.1651738389974; Thu, 05 May 2022 01:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651738389; cv=none; d=google.com; s=arc-20160816; b=ZJfGPS76BSZ6K2Fyb9s2n6nYQj3Bmc/lO+Dz65dF71q5qJD0OoSfBPR2HQ8LOGm1od FazI1y4JayU7ALw/6ncyAiY68Bv8tJTdiGop9gm71K35rSQ2mEhpv2apOhsngrTpxKmc f+zJ031wx4ImPA5/WBY7O8zlagPEHTBV9GpqG1SS8CHwKa63MRz8HatOPExZgF4bhkpV bP82/JsJ8WTR95GXJSNOTYq2RNCYF/VClbo6mDgLuf8XQ7hlzSX+46D1RUhOSJb0Wl5l DTCbb9vFAtLBR/UV5300OaI8VW/7dEK1nyz/OZq5MYPEpjuh2vrB4sLCKDZX8FRjYozI orNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=kKuGwdSJtS+WiXghVoIOPpH32AVOKBI/15oCiMuq+jQ=; b=xBcABEcYKbcJmu0wGBUJkUAFnp+cjierr80EIjmhPFbfgrnzmPhwTBKLwGuy6GaQhp OtQUtxjJBhMrfQsYELBhlV9oJWTdHxX5ykWS5pZwEZ3gRDl7BQRA/ZLI4eNX0zwUAd9b 0Ui9YWOhC8p79YMHZLp4kMnmfzA8yjLEny5c0G89M80YI5pRpT4rJgdTp8kbztZySuQ7 9EcF3v8Lqa0NRdScll9cPZ3dOE/u8RqmuF5edPHBRaw62oGj0abW1r5ZXOAH66pfieWH 6P3E1bDPwmZ9arrXsyzrT3o6d850D3keSVS+N16vIOUVecV3BXLxrmnrz1DDeIQ06rj3 2XmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mlX+me3N; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e19-20020a63ee13000000b003aba3fbb424si705720pgi.669.2022.05.05.01.12.55; Thu, 05 May 2022 01:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@linutronix.de header.s=2020 header.b=mlX+me3N; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235287AbiEEBZX (ORCPT + 99 others); Wed, 4 May 2022 21:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiEEBZX (ORCPT ); Wed, 4 May 2022 21:25:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60EF506FD; Wed, 4 May 2022 18:21:45 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651713704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kKuGwdSJtS+WiXghVoIOPpH32AVOKBI/15oCiMuq+jQ=; b=mlX+me3NOGEr2QS8iofK25Nzt/JMyKvAWUFvlEBfi3vgWJWAbGFlCJZZBCi9XfpgkVGdTp ezzlLg4sna1GNariY6xv6alMom9mPBIouX8Dz2xknquqKah6lac/eiY40VaI1BdYxv6+kz Rsi9x2ic0FV2GhKQ2a5iLUEkxa80w9VhYdzzIOiChlSow5SrbTchqbqhobT4Kcta8tBYu9 u/rOBZfDm6UYayws4BisIIPNBInm0iKwNm+3i3iBGIan9fTxv1DLqdlwe8dxtP5qhYd0Xa BkJMpAmi9qf0duNXFF/25xIvCndY8vKkScVwYD/cAMHO+ZlKsLlokQ0ReZ/Xpw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651713704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kKuGwdSJtS+WiXghVoIOPpH32AVOKBI/15oCiMuq+jQ=; b=ah23Qu7hQPYvzXRQTkxFXgnobMZPJBL9gXOSfAFn0Ru7tgFXZpLOI06TDd8B5iP1IE87o4 Uv3voCCxRFzNvIAg== To: "Jason A. Donenfeld" Cc: Peter Zijlstra , Borislav Petkov , LKML , x86@kernel.org, Filipe Manana , linux-crypto@vger.kernel.org Subject: Re: [patch 3/3] x86/fpu: Make FPU protection more robust In-Reply-To: References: <87k0b4lydr.ffs@tglx> <87fslpjomx.ffs@tglx> <87czgtjlfq.ffs@tglx> <87wnf1huwj.ffs@tglx> <87mtfwiyqp.ffs@tglx> Date: Thu, 05 May 2022 03:21:43 +0200 Message-ID: <87h764ixjs.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-crypto@vger.kernel.org Jason, On Thu, May 05 2022 at 03:11, Jason A. Donenfeld wrote: > On Thu, May 05, 2022 at 02:55:58AM +0200, Thomas Gleixner wrote: >> > So if truly the only user of this is random.c as of 5.18 (is it? I'm >> > assuming from a not very thorough survey...), and if the performance >> > boost doesn't even exist, then yeah, I think it'd make sense to just get >> > rid of it, and have kernel_fpu_usable() return false in those cases. >> > >> > I'll run some benchmarks on a little bit more hardware in representative >> > cases and see. >> >> Find below a combo patch which makes use of strict softirq serialization >> for the price of not supporting the hardirq FPU usage. > > Thanks, I'll give it a shot in the morning (3am) when trying to do a > more realistic benchmark. But just as a synthetic thing, I ran the > numbers in kBench900 and am getting: > > generic: 430 cycles per call > ssse3: 315 cycles per call > avx512: 277 cycles per call > > for a single call to the compression function, which is the most any of > those mix_pool_bytes() calls do from add_{input,disk}_randomness(), on > Tiger Lake, using RDPMC from kernel space. I'm well aware of the difference between synthetic benchmarks and real world scenarios and with the more in depth instrumentation of these things I'm even more concerned that the difference is underestimated. > This _doesn't_ take into account the price of calling kernel_fpu_begin(). > That's a little hard to bench synthetically by running it in a loop and > taking medians because of the lazy restoration. But that's an indication > anyway that I should be looking at the cost of the actual function as > its running in random.c, rather than the synthetic test. Will keep this > thread updated. Appreciated. Thanks, tglx