Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp598854ybz; Wed, 22 Apr 2020 04:29:13 -0700 (PDT) X-Google-Smtp-Source: APiQypLfFapy3IVcGcOCXoNbSYSaPhxFb08zY61HFYWiAMxfy7h5NlByb3yA9QxZDT/EIQsLmNJX X-Received: by 2002:a05:6402:22ea:: with SMTP id dn10mr13557768edb.70.1587554953528; Wed, 22 Apr 2020 04:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587554953; cv=none; d=google.com; s=arc-20160816; b=VmeANgaY9HVZNC+FemjH0RmcDT9ZhMsLYHaK0DHR3qoCu2bFRE2xp44ZVc2n5/GsE5 IJq1AcfjyO4VapllgknoMsfNcEgntVuMUCaY0ePrS/o5sETnKNbRI+naTsh3GfAfNQvf ey9Y7ScciFPoIvLtlE1CP6HOWhN0i0KcS4u+ED42XvDuUy/XEX5eeFl/ZKaVh4M4cUoz jqm/aaKp6AYMjdQoZc8qa7xoPjkam0W/vuxB+mhtPhflweOEj+osWOBj+eRscpVWpgwA wYJyVpKAESl7+igAb8GICzqvUJK3jInlqnTEiHGhvfVfo+XCRhfEf0RfDtPiM+TqOXmU BmEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=x8iDISKFY46bmr46LSbp/SvtaRsnYdPbRRVlbZD6NaA=; b=bNs8yvSmeiYhXG7aQWiC2M0pE7X4q/S4P2VA2Y+ZHWx7l0ZVKkWFc/B0kGY/rOtYLP XyEGLXmj/Hjb9wA6tyHWOKZZFZHZ9QCb+Nsq4SkZy/S8/qxwUqzUV8ayZjMU4ypGrYrO 8CgJAiIXBuG0toVervyzVNpS076MVVdyac5tLIhT0oIrPgvH7kHeLOc9Ui7o7v9pTEIY OF6PD+vNO3HCcEu9PgSCQQJ6h/QjQR92WVM6NkeLm1jeHWgwTyIkIknRo2NTsbwGRRc1 GSOcZUFXlbnvrrG81zAs1c1ToJCHZn8HtJKoZ9vYaXC0N340TvNs7ObNW7OVahWfX0xI napg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si3658838edh.59.2020.04.22.04.28.39; Wed, 22 Apr 2020 04:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726117AbgDVL2g (ORCPT + 99 others); Wed, 22 Apr 2020 07:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725808AbgDVL2g (ORCPT ); Wed, 22 Apr 2020 07:28:36 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7697AC03C1A8; Wed, 22 Apr 2020 04:28:36 -0700 (PDT) Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1jRDYN-0006fw-5o; Wed, 22 Apr 2020 13:28:31 +0200 Date: Wed, 22 Apr 2020 13:28:31 +0200 From: Sebastian Andrzej Siewior To: Ard Biesheuvel Cc: Eric Biggers , linux-rt-users@vger.kernel.org, "Jason A. Donenfeld" , Herbert Xu , Linux Crypto Mailing List , Linux Kernel Mailing List Subject: Re: [PATCH crypto-stable] crypto: arch/lib - limit simd usage to PAGE_SIZE chunks Message-ID: <20200422112831.5352gcpo42jgz2dj@linutronix.de> References: <20200420075711.2385190-1-Jason@zx2c4.com> <20200422040415.GA2881@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2020-04-22 09:23:34 [+0200], Ard Biesheuvel wrote: > My memory is a bit fuzzy here. I remember talking to the linux-rt guys > about what delay is actually acceptable, which was a lot higher than I > had thought based on their initial reports about scheduling blackouts > on arm64 due to preemption remaining disabled for too long. I intended > to revisit this with more accurate bounds but then I apparently > forgot. > > So SIMD chacha20 and SIMD poly1305 both run in <5 cycles per bytes, > both on x86 and ARM. If we take 20 microseconds as a ballpark upper > bound for how long preemption may be disabled, that gives us ~4000 > bytes of ChaCha20 or Poly1305 on a hypothetical 1 GHz core. > > So I think 4 KB is indeed a reasonable quantum of work here. Only > PAGE_SIZE is not necessarily equal to 4 KB on arm64, so we should use > SZ_4K instead. > > *However*, at the time, the report was triggered by the fact that we > were keeping SIMD enabled across calls into the scatterwalk API, which > may call kmalloc()/kfree() etc. There is no need for that anymore, now > that the FPU begin/end routines all have been optimized to restore the > userland SIMD state lazily. The 20usec sound reasonable. The other concern was memory allocation within the preempt-disable section. If this is no longer the case, perfect. Sebastian