Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6410923ybn; Sun, 29 Sep 2019 19:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwt84Hf4QZDn9eHUHzsuyBt8PdalQ1jkjj11BurElG8x2M5Pj+4h+8FgTD5b/uBkwPZLUrS X-Received: by 2002:a50:f603:: with SMTP id c3mr16886956edn.208.1569811468526; Sun, 29 Sep 2019 19:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569811468; cv=none; d=google.com; s=arc-20160816; b=IG/Ht+IJpaiQwjeB4Rc4vkyhYkm6SsZTIRr52PeJ7AmtKZukvEzSMdwg0Rf3uvrp9f 47RGYSNb+l+ODFoipEoWty6Of8+ZcWJLeasNt6hXqmODiAYYrAbH8y/8fFeJsjhCq6Du 7VxvpYuU69UhfmteV7ps5/yA5RFZAfeE93VYwxVRBFxcHttBULPaSPaS4qmoKd4JPISg 1WEveSkGvcP0kw/Z+gWZPuLHGQxMbYVWHD57q1w1SBKNPbhKIu+XyjriHQEq/ck3NCT8 8+JmCjTWUtaV92Fg9kwd1Zjt1h4Nn8xLjdsHpPdfoN2ycmLcC5UgmJpkno5pSLSBXjGV BT8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=I+GT0X1olH3ZtKp7vABTiyJUY2gtTKpvtvwxQSPaiG4=; b=qJ2c76BsDANb+96rBcioDlmrS37HA6uH7OR7iqvyVznjk6YZ3jVxD37n5JD5ElqgTm XeHNFyQKGuwthB81OBHvtTqA7ZNDMe+htjpvbjJmBNcBLAiWKdnsY3b//mgM4n0fCVP1 b+xey7j1PE2ssnhtIIlCDXl10qqL/QRuTqOKRVgqjDR4ffuwL++l5Uhq2JJYuVR1brMR F3ZCtpL59+HzN1QhRHywj0271LneoijZK/usXjlk6tYdMR1Gk7BwoVZXEMctODiINsqd sPW4wkVvu7toK4wHZtBwe7xQFatNa5ACTrw/11OsEQecgcWCJ4AKQvnoIj/QLZ0tInqq VzsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=Ly8deA0h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ox10si6301960ejb.325.2019.09.29.19.43.51; Sun, 29 Sep 2019 19:44:28 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=Ly8deA0h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728853AbfI3CmW (ORCPT + 99 others); Sun, 29 Sep 2019 22:42:22 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:44183 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbfI3CmW (ORCPT ); Sun, 29 Sep 2019 22:42:22 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 2a434cd0 for ; Mon, 30 Sep 2019 01:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=5Vsj6EXf0jjuUV8wzSrKzacZD/I=; b=Ly8deA 0hY4MSQuTheWCk3bmmN21Sjy3I48IOn71+eHa55jX16q+7HZt7tbFKc4z96WzkOu zGWhPv2JO3nUhxxL+hO6JmfDMS2xTWdS821s5IKBZfkVeCSBmbtlawmn8P5viXp6 PT6yFj62EHLORtVyPjTWGYHETLRcSTTYJ/6Y3YMcdQCOnF2ngiUQ0+9yTq+yUXMu BL28GyI1sLi/GlUzg2r4JUA2B++BYQeIpnhj3mgLfkROB+D568HTC0Sfk+FO7fPr w2Xjz5QYMKLjyceyr+1gSkuSoKxgHkyJVR+f1Z3QCZVFOxRyjg0BGB/QOqwWE3UC JvDHwerwmpBxE9Ww== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 36046498 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Mon, 30 Sep 2019 01:55:59 +0000 (UTC) Received: by mail-oi1-f179.google.com with SMTP id m16so9821796oic.5 for ; Sun, 29 Sep 2019 19:42:18 -0700 (PDT) X-Gm-Message-State: APjAAAVfQQtnF1haWGsPeqVBZ9wy0DbNrkhpWpo2Hf4REuR1+sSiZegu CYN/VafFaY3fNpo7foP7RKbSh0yjPqFbxu8G014= X-Received: by 2002:a54:4807:: with SMTP id j7mr15044988oij.122.1569811337466; Sun, 29 Sep 2019 19:42:17 -0700 (PDT) MIME-Version: 1.0 References: <20190929173850.26055-1-ard.biesheuvel@linaro.org> <20190929173850.26055-12-ard.biesheuvel@linaro.org> In-Reply-To: <20190929173850.26055-12-ard.biesheuvel@linaro.org> From: "Jason A. Donenfeld" Date: Mon, 30 Sep 2019 04:42:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 11/20] crypto: BLAKE2s - x86_64 implementation To: Sebastian Siewior , Thomas Gleixner Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Sebastian, Thomas, Take a look at the below snippet from this patch. I had previously put quite some effort into the simd_get, simd_put, simd_relax mechanism, so that the simd state could be persisted during both several calls to the same function and within long loops like below, with simd_relax existing to reenable preemption briefly if things were getting out of hand. Ard got rid of this and has moved the kernel_fpu_begin and kernel_fpu_end calls into the inner loop: 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? Regards, Jason