Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1051235ybz; Wed, 22 Apr 2020 12:37:25 -0700 (PDT) X-Google-Smtp-Source: APiQypJYWT3uFJ8qLiXUGlcpPMi9pWyol9MDdkZqj0SvVphGalR66GTLWlUeNas8bjArf5ZmIQWI X-Received: by 2002:a05:6402:8c1:: with SMTP id d1mr190324edz.236.1587584245406; Wed, 22 Apr 2020 12:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587584245; cv=none; d=google.com; s=arc-20160816; b=brqc+CwRcQd1/At5NZkhnSB9gt7F23oYm12CqZEhILk1ScA43Zl6zJOjTlwa70Scve MZ2a/j7gLLDGZTIJCfkHcBglJrcNxYLx26K/8fxKsZ7fQu4j9yQP4m6rOGsuPzCz3mG5 RQcKs/W9MB29cccF01T2S8WbOXGGkKvVGPjqVLfJxQqrlrCN6EY77mjBgf+uwU7uIJpQ JGX4OcPJvriCJ+AXHjYM35b95doIAGXsTncjvGSoBrM9ncz+aCf0LdZ+mXPRANS9CWAF 0TQwW2fzgeI0LtUSaA4J++3eUG6fjw8xgBTVFZGKRDOKVjIDidEnt+3+zXKEiRIaputI qpZQ== 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=5NLRkhqEJPDoLdEBwMY9/B8ISri3MKnTI/y3R63EzsM=; b=m46ZpwJH9KTnaeiQ0aZvNaRq0AN7TKr+yb4PQyK27/fV+8xFmVNQyngXiPWdPDxpCO wwJgdpW2AZrLmLDwy4mOK8kmmJjoAQqzt25xQoZJuEFZxgA1IgJMEywy0CRHTdPA4hyB hMYXpa8jSkmmtO6etLHkoeOmwIeRiqsWy6MxvYI1QHGJqaTZw+y5DiuU0ZDhTVP9svfE ex9vUrqWSBiFndUNVlJYkeW/TBvMW1Vf9RiC9E3SSRHaZcWGzmTTQSoMZTM5+pWxy2j9 URBHC8uY/2v8NTIBQxj1BBr0HGvxreC2Ib8WRL+zfKb8hKqUtVp8FckReE2Y6JduRsyp a5ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=SmMEoWFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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. [23.128.96.18]) by mx.google.com with ESMTP id i26si47600ejg.474.2020.04.22.12.37.02; Wed, 22 Apr 2020 12:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=SmMEoWFm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726540AbgDVTf1 (ORCPT + 99 others); Wed, 22 Apr 2020 15:35:27 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:51183 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726398AbgDVTf0 (ORCPT ); Wed, 22 Apr 2020 15:35:26 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 4da5aa45; Wed, 22 Apr 2020 19:24:28 +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=G14/T8eEI9TeQPnPJ5D0ORWfR+4=; b=SmMEoW Fmf8RU8JIiKbBUmEZwRnnNXQvw29LJc/OTni7TAQ8UhqgT4VYHNHkhOuGfvzC8rl 6ie63Yd75cc/Qb8JyFSAq+R8tmxtjjlFG5rGymabsXeFeVLZD3xjXcRoti9lH1yn BECMW0uWF4lv9Qs4mX4feUK768vGN1toYB45OOpZv+7YbiOqP0MLpCebR1bv2fJD 5kn3Hhuwu+p0+soDCglxzfVgFWKSQokOi3pB5mgjWCnfaHTurjFUCZocZ1eoGX1H e6sPI3u+of35ds4g/s3/pFy3Nkfmpi9EsEfNhjlYFdKYIutg3uVHEZfRsRWG5nGE vviy99rKd/h8jKHQ== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 8d1ff259 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 22 Apr 2020 19:24:28 +0000 (UTC) Received: by mail-io1-f53.google.com with SMTP id 19so3726651ioz.10; Wed, 22 Apr 2020 12:35:22 -0700 (PDT) X-Gm-Message-State: AGi0PuaO2HejiyjDx/S94XoAU1uHa0bU5Rw/cTxQVjZkKSHL556Tkmcp e1R25jGyCb42hlfCJ/ql7DIfK2EvnL4Koqctig0= X-Received: by 2002:a05:6638:4e:: with SMTP id a14mr21577jap.108.1587584121233; Wed, 22 Apr 2020 12:35:21 -0700 (PDT) MIME-Version: 1.0 References: <20200420075711.2385190-1-Jason@zx2c4.com> <20200422040415.GA2881@sol.localdomain> <20200422112831.5352gcpo42jgz2dj@linutronix.de> In-Reply-To: <20200422112831.5352gcpo42jgz2dj@linutronix.de> From: "Jason A. Donenfeld" Date: Wed, 22 Apr 2020 13:35:10 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH crypto-stable] crypto: arch/lib - limit simd usage to PAGE_SIZE chunks To: Sebastian Andrzej Siewior Cc: Ard Biesheuvel , Eric Biggers , linux-rt-users@vger.kernel.org, Herbert Xu , Linux Crypto Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2020 at 5:28 AM Sebastian Andrzej Siewior wrote: > > 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. Cool, thanks for the confirmation. I'll get a v2 of this patch out the door.