Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11143011rwl; Mon, 2 Jan 2023 15:04:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXsG3cU3rRo7Kv3iO60TU9KMTo3Vtbt9UwxZuGkiQPJ+dsIEu8KgU7UFJsAgsQ745VtO4THr X-Received: by 2002:a17:907:a50f:b0:7c0:d609:6f9b with SMTP id vr15-20020a170907a50f00b007c0d6096f9bmr39601452ejc.27.1672700653510; Mon, 02 Jan 2023 15:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672700653; cv=none; d=google.com; s=arc-20160816; b=S1v4AqDtvQ+sA+9Dm7SYAFFs9XGTyvUMZS/WnKdOJykQIhHbHpiaT1nxXImGbciHvK d1sMtvlrJ4U1VZ7tZhwf1eOwvt568YWre5yYqtAdSlx9o/xpRnl/KvqOU224B0AJdv55 aakKfnLYM1vDiD/Mae4PEeTEcCeEWWtoabhmEFLjpiwia1yXjtTfOEIrLlVhoO2ivRda GcQ6W2dCjobR9WQhGIOJie51pk6CQ7sg51JIYLs68yCQ6MIIwhEmxgP5b2UzClutfM4Z IYuC054L8P3TyZ0aurw1HfUfP74u1+uKR5RR2IL2OPQpf3kt58mprrccnN+qrvcRh6vT B6eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=J9giiBGH+QXyA2ijyx45M8Ora95YYDZd/jJVFsCZDv4=; b=uPW7heQV3lPQyqPUWQXX3wh0C86P+RvbMsf80XDwX+biuRIQ0LWwT88xMsEi8Bd/Rm kgoE2e38ev2/Q5b080CB0pTzCHhldVQTz83evwlZ928SNpfNGYewB8iDfW7d+WcokqFl CwYXHpJX6OnNhI6+k//CfDVnlu7SDbgqhmHmFHSdwFuAt5VmwHOH+ehVXy/oet0oE2IR kceoy5FpPE6h33TqFLu10lCB2E6HArCKnsQaE9d3o1KuXQaHkcU5IcKKzrR82wOtVA7A vHmp5nFXXXH6kBdm7a/DbND5NiBbD2IqrRGIc1gPhx2sxIzVbpGTkotp8yibMWzgAJ2L /7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HN1j2lr0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw15-20020a170906478f00b008244db32413si27351439ejc.445.2023.01.02.15.03.46; Mon, 02 Jan 2023 15:04:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HN1j2lr0; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjABXDp (ORCPT + 99 others); Mon, 2 Jan 2023 18:03:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjABXDo (ORCPT ); Mon, 2 Jan 2023 18:03:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9092ADB for ; Mon, 2 Jan 2023 15:03:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3221561133 for ; Mon, 2 Jan 2023 23:03:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 687C8C433D2; Mon, 2 Jan 2023 23:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672700622; bh=rmpZSqBeydYPmOfYdtaHXGU6tk3QdqLm4wRRYorlwEQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HN1j2lr0Uj5Ctr2FeCQ8/Bwq8ez/QynvNXHcnOB8yt1NMuo4IlqiuI3tO/qb8v51x 1TTDuEnO6sff953TIK2nWXsUtPweL3rIKZ2CpRc0QIygLN9uyMdgfOhJUOaEz27MNR q19qEGavSV8ubWUAO8VycW1MPFXDKkCIOc2/P6Kqk6uljuysQWP+IVrDDDV/3aVjxJ LODWsHopBcnA8K6Ytysqi97Bu7JS5oEdpj3nuXxT+4ZaPOBEvHNaQoL7CbZ6zhfiRX fKZxW6aOm4OFm5edASjU5n1dRXU7Sw3OnUZREpDgZ+r3jYOoJvmKhCDF71pS2NRvdZ rt4KfQsL4JgZQ== Date: Mon, 2 Jan 2023 15:03:40 -0800 From: Eric Biggers To: Lukasz Stelmach Cc: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org Subject: Re: xor_blocks() assumptions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jan 02, 2023 at 11:44:35PM +0100, Lukasz Stelmach wrote: > Hi, > > I am researching possibility to use xor_blocks() in crypto_xor() and > crypto_xor_cpy(). What I've found already is that different architecture > dependent xor functions work on different blocks between 16 and 512 > (Intel AVX) bytes long. There is a hint in the comment for > async_xor_offs() that src_cnt (as passed to do_sync_xor_offs()) counts > pages. Thus, it is assumed, that the smallest chunk xor_blocks() gets is > a single page. Am I right? > > Do you think adding block_len field to struct xor_block_template (and > maybe some information about required alignment) and using it to call > do_2 from crypto_xor() may work? I am thinking especially about disk > encryption where sectors of 512~4096 are handled. > Taking a step back, it sounds like you think the word-at-a-time XOR in crypto_xor() is not performant enough, so you want to use a SIMD (e.g. NEON, SSE, or AVX) implementation instead. Have you tested that this would actually give a benefit on the input sizes in question, especially considering that SIMD can only be used in the kernel if kernel_fpu_begin() is executed first? It also would be worth considering just optimizing crypto_xor() by unrolling the word-at-a-time loop to 4x or so. - Eric