Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1520617pxb; Wed, 4 Nov 2020 11:08:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8un1FlmTt5583oo8EyTgSkTobrF6opstH5rMyGMUJV1w69A4RKtGhq7tjw+ecVE9KW+rJ X-Received: by 2002:a17:906:43c7:: with SMTP id j7mr2699700ejn.397.1604516898991; Wed, 04 Nov 2020 11:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604516898; cv=none; d=google.com; s=arc-20160816; b=sDxH39/FAEqXJhfcbPA06bDw1sro1VRpKMK3e4igvU/W1jVVb8HOOMXD3L1/Fj8BI/ OQcDUPFwZQNfRAQL7Ytdip+B5IpqCl1ZYUsOavsX0l7QlzxLXdmqYB5uSGYEtejYFdVK H1/4gjtj24Pzr24GfLVdK4cDYtBJ2iioxz23Kn0A3naYRroDmcZywc1BWAUiv28G2Qav D6ZVn6qublRn9XF6dZSDMdCbeoGPTd5cbGZli3BScpajO0BaoYsJ+rLFJM2DmF1ZegLj 2hisdkPDkD80voANx5A0uMtmkLSDUlxkR9A5oa+tE6mWeAj10rSjpsiLw/zyw1g36/AF ulpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=pOpzKECKmGl1+UYkchE+AHh8j9fc3azaoJO8esvsHAg=; b=YSDt1w692epxWruICwuIxCylr23ABhDei5s2ZfxggEHyGYuv/K+NdGPOmIjMmh7UOL joBtj8ukIhcmG5rHYNw0F242czzfBXyavTVwMpYKl4XqMCOr+5KVDacNvx2XUz8wa9Lv KRezZuZoiE3Y4UcFKcP9hov366Abpctxjo+xqcvUy4AXEyelu53u7f7kXxuTfbpAdYzV MMFg5/Zo7ePJQqShyYJtgxB82PjzTviZPEBWMaKTZvNQCmEX89ik8hKPxHY09bY3b1xK puvjfvImtXly2A43cJHvoqvhHDb7SnMjTOoXm/dMNdj6dRg7AEq2wtTlmlZug/LnB9Hl Z8cg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si2341425edy.27.2020.11.04.11.07.55; Wed, 04 Nov 2020 11:08:18 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730340AbgKDSNM (ORCPT + 99 others); Wed, 4 Nov 2020 13:13:12 -0500 Received: from foss.arm.com ([217.140.110.172]:41536 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730052AbgKDSNM (ORCPT ); Wed, 4 Nov 2020 13:13:12 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8473414BF; Wed, 4 Nov 2020 10:13:11 -0800 (PST) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 18CC63F718; Wed, 4 Nov 2020 10:13:09 -0800 (PST) Date: Wed, 4 Nov 2020 18:13:06 +0000 From: Dave Martin To: Mark Brown Cc: Alexandre Torgue , Catalin Marinas , "David S. Miller" , l00374334 , Linux Crypto Mailing List , Maxime Coquelin , Will Deacon , Ard Biesheuvel , Linux ARM , Herbert Xu Subject: Re: [PATCH 1/1] arm64: Accelerate Adler32 using arm64 SVE instructions. Message-ID: <20201104181256.GG6882@arm.com> References: <20201103121506.1533-1-liqiang64@huawei.com> <20201103121506.1533-2-liqiang64@huawei.com> <20201103180031.GO6882@arm.com> <20201104175032.GA15020@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201104175032.GA15020@sirena.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Nov 04, 2020 at 05:50:33PM +0000, Mark Brown wrote: > On Tue, Nov 03, 2020 at 06:00:32PM +0000, Dave Martin wrote: > > On Tue, Nov 03, 2020 at 03:34:27PM +0100, Ard Biesheuvel wrote: > > > > First of all, I don't think it is safe at the moment to use SVE in the > > > kernel, as we don't preserve all state IIRC. My memory is a bit hazy, > > > I'm not convinced that it's safe right now. SVE in the kernel is > > unsupported, partly due to cost and partly due to the lack of a > > compelling use case. > > I think at a minimum we'd want to handle the vector length explicitly > for kernel mode SVE, vector length independent code will work most of > the time but at the very least it feels like a landmine waiting to cause > trouble. If nothing else there's probably going to be cases where it > makes a difference for performance. Other than that I'm not currently > seeing any issues since we're handling SVE in the same paths we handle > the rest of the FPSIMD stuff. Having a random vector length could be good for testing ;) I was tempted to add that as a deliberate feature, but that sort of nothing doesn't really belong in the kernel... Anyway: The main reasons for constraining the vector length are a) to hide mismatches between CPUs in heterogeneous systems, b) to ensure that validated software doesn't run with a vector length it wasn't validated for, and c) testing. For kernel code, it's reasonable to say that all code should be vector- length agnostic unless there's a really good reason not to be. So we may not care too much about (b). In that case, just setting ZCR_EL1.LEN to max in kernel_sve_begin() (or whatever) probably makes sense. For (c), it might be useful to have a command-line parameter or debugfs widget to constrain the vector length for kernel code; perhaps globally or perhaps per driver or algo. Otherwise, I agree that using SVE in the kernel _should_ probably work safely, using the same basic mechanism as kernel_mode_neon(). Also, it shouldn't have higher overheads than kernel-mode-NEON now. > > > I think it would be preferable to see this algo accelerated for NEON > > first, since all AArch64 hardware can benefit from that. > > ... > > > much of a problem. kernel_neon_begin() may incur a save of the full SVE > > state anyway, so in some ways it would be a good thing if we could > > actually make use of all those registers. > > > SVE hardware remains rare, so as a general policy I don't think we > > should accept SVE implementations of any algorithm that does not > > already have a NEON implementation -- unless the contributor can > > explain why nobody with non-SVE hardware is going to care about the > > performance of that algo. > > I tend to agree here, my concerns are around the cost of maintaining a > SVE implementation relative to the number of users who'd benefit from it > rather than around the basic idea of using SVE at all. If we were > seeing substantial performance benefits over an implementation using > NEON, or had some other strong push to use SVE like a really solid > understanding of why SVE is a good fit for the algorithm but NEON isn't, > then it'd be worth finishing up the infrastructure. The infrastructure > itself doesn't seem fundamentally problematic. Agreed Nonetheless, working up a candidate algorithm to help us see whether there is a good use case seems like a worthwhile project, so I don't want to discourage that too much. Cheers ---Dave