Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6618145ybn; Mon, 30 Sep 2019 00:36:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSLJnVhNTjR5ywRCRaSyxX+PdEfjuy2IWibeMKzVGB2mfvqPx+Bc/FmLFhFpQJSyHD7PDm X-Received: by 2002:a17:906:fc2:: with SMTP id c2mr17786785ejk.261.1569829004515; Mon, 30 Sep 2019 00:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569829004; cv=none; d=google.com; s=arc-20160816; b=ORB8s3FXPuAIuAjquQliTxX4rc5r+e6LtByRJM2+mlcoOgKj/fP2x2NtQ8cHHvkw9+ 8DqhgX2Y38JGTHsE43rH5qzCA4AJDSAPj9+jN5FEAb+p4lErbnuxeYBdPAEeeORa2PJ7 PIyd95r/UsnQPNRtSZIIvKKxti1+daaQe1pnA1QMTQX4siLD2BLTidLjX6NPL/SllGKd sAPSU71JhfHNufcdU28IEZJ6/QbYoPrqGSeg7Wp9M8XL1GMCOSL0YnV+tBCJS02jFaVT 19g/lMIBrEcXjMQbXjnPyd1gux9hZuQ2WzIJWTVPYenFVmok0MIaI34CL9DtDK9cEfai Hvtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=R26mLMAUxfQzOZgax5BuaNUArtkdZIvYT+xTWw57gwg=; b=x60c7EhbjTHEHJKug29BP8EDwR7dxVwFKXRbiEXr3KXy+xb47U2UrwCS+NC3kK6pC7 Xdd4lteREd86NKDuuj0oZsgMP8FSNMVoIzgwzILz3rcQuDiHGxwLV2ioL9OSewX1oh8y LiM5lXBOlsufphSiez0mraMiy5FGeK9MQVFo/OPeUJTNP2PBixYvwIeKo2OSrYqtDAav ZV0P2RBAm0PAfsclD2c5Jx921O24J+X1gZuF0ZXrfIEf70frz1CVObk0BXnUtgx0x/O2 gaws3ZlY3nhc64kS0hNciV5x4x2lzqYuMkHsmskapwtV8sVnx6Im9nZ69aTqaDd1vRRn Z8Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sa16si6693791ejb.356.2019.09.30.00.36.16; Mon, 30 Sep 2019 00:36:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729254AbfI3HgG (ORCPT + 99 others); Mon, 30 Sep 2019 03:36:06 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51098 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfI3HgG (ORCPT ); Mon, 30 Sep 2019 03:36:06 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1iEqDp-0001nY-P4; Mon, 30 Sep 2019 09:35:53 +0200 Date: Mon, 30 Sep 2019 09:35:53 +0200 From: Sebastian Siewior To: "Jason A. Donenfeld" Cc: Thomas Gleixner , Linux Crypto Mailing List , Ard Biesheuvel , linux-arm-kernel , Herbert Xu , David Miller , Greg KH , Linus Torvalds , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas , Martin Willi Subject: Re: [RFC PATCH 11/20] crypto: BLAKE2s - x86_64 implementation Message-ID: <20190930073553.xy57e75nteiakjyp@linutronix.de> References: <20190929173850.26055-1-ard.biesheuvel@linaro.org> <20190929173850.26055-12-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2019-09-30 04:42:06 [+0200], Jason A. Donenfeld wrote: > Hi Sebastian, Thomas, Hi Jason, > On Sun, Sep 29, 2019 at 7:39 PM Ard Biesheuvel > wrote: > > + for (;;) { > > + const size_t blocks = min_t(size_t, nblocks, > > + PAGE_SIZE / BLAKE2S_BLOCK_SIZE); > > + > > + kernel_fpu_begin(); > > + if (IS_ENABLED(CONFIG_AS_AVX512) && blake2s_use_avx512) > > + blake2s_compress_avx512(state, block, blocks, inc); > > + else > > + blake2s_compress_avx(state, block, blocks, inc); > > + kernel_fpu_end(); > > + > > + nblocks -= blocks; > > + if (!nblocks) > > + break; > > + block += blocks * BLAKE2S_BLOCK_SIZE; > > + } > > + return true; > > +} > > I'm wondering if on modern kernels this is actually fine and whether > my simd_get/put/relax thing no longer has a good use case. > Specifically, I recall last year there were a lot of patches and > discussions about doing FPU register restoration lazily -- on context > switch or the like. Did those land? Did the theory of action work out > in the end? That optimisation landed in v5.2. With that change (on x86) kernel_fpu_end() does almost nothing (and so the following kernel_fpu_begin()) and the FPU context will be restored once the task returns to user land. (Note that this counts only for user-tasks because we don't save the FPU state of a kernel thread.) I haven't look at crypto code since that change was merged but looking at the snippet from Ard is actually what I was aiming for. > Regards, > Jason Sebastian