Message ID | 20230306185226.26483-1-tom.zanussi@linux.intel.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2024951wrd; Mon, 6 Mar 2023 11:14:39 -0800 (PST) X-Google-Smtp-Source: AK7set8pJGbW2H8bCC3QMJNcZAsRPXGJE6+NDc4BnO6ijkj09PgimF3sbZIiOAMbmYV//vDCkJHz X-Received: by 2002:a17:906:c301:b0:8b1:7684:dfb0 with SMTP id s1-20020a170906c30100b008b17684dfb0mr11858821ejz.57.1678130079262; Mon, 06 Mar 2023 11:14:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678130079; cv=none; d=google.com; s=arc-20160816; b=i5pJepo9Iomh3GNJ+PJQuuNWsUS554saz1zEC3GIBWF5mKMbAe49Fo/rJQaMgOZXwj 5Cvw5EXUC+QrEbfdS5jfnLBOVwoVwGpT1nK80KR4crftiqIaqDT1a7hGWIbnjEr4wQRU cD+LOZlO6/tkdUqYw45PxHzhzxZ36z+Ump9bmQLAEXJ+6b462Obsroo/9LMyVFFrVUKc XfCur/2EVoYiU+NFk9RQRNTrp8+6DJcsJ3RhtJ2sbs6f56u10+6u1r+qUSLr+7AZt1VC WfOiG0lLCYx2Oh3hY4FBnn+y0Ipb4F6/1qBpZ4q8fmFC7BZOXyPYcAL9oQBDA361SUy0 xBDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=YbVQZb4SKdc8nxs3xv9W2D9QE5FVLYywJFjNloiWtQA=; b=U+oY11Q9eal34/1oIB+fVI8IIpWqZUKk0X9ZfNdRJcB9VI2pYHTYvLklSfMKfGMoPN F7aD6NLfUTGfEghVk1uh8IsFNsTZIN8DQf38CSRN2YHg/NgnmOQGmfY4RbLCJo5YXZXj MqcjZ2PIfJ8h+AZLyhiYXYc2tXzc3MYf9JIAEBRjaOQMQwd+nmlio6nkTWe7sXSXKvb2 dPnRrgHYqS8KAQz+mS3OPrH9cKZcaWN4BNOoJFekEBq3ufOm/MeLwTx4XqWF1UE0e0+q 4IR/+eurDCGZVrCwovvmg7i6AY3tU3a9vPoTGfRkt/GnsJSZ8MVJQhkRfVO8KwYLO4UM B7rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G0ZJj+TR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jy2-20020a170907762200b008ca1ab4dc33si1231143ejc.159.2023.03.06.11.14.15; Mon, 06 Mar 2023 11:14:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@intel.com header.s=Intel header.b=G0ZJj+TR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjCFSwi (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 13:52:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjCFSwh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 13:52:37 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC824AFC5; Mon, 6 Mar 2023 10:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678128755; x=1709664755; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=b3/J//9BRvy9p0fhsU2LeJiaZAgIJk+YU5NTytqT8ko=; b=G0ZJj+TR8g+j+X/8lENhYABvL3SRi4yvGSF8nRkG6NXyNJQMiiIdd9us mwT4NsOfFUS8B4jzgdiXi9XJjKhQ+6BwYZ0VNER4WCXIwiPvpAVPq55CA 4s+tm/u5ukmUWAnRLAQH6rlFLqMbFK0ZkhTXnh+jlYBlUlZ1StU61swuu SG/5yftWom5n0AyMyJTGSEGcLf0PtR+M2PCtB1OZ/PPt4TGf4O/ES6SQj sNQSpP7xdvezMH9VxrnAJoKVItpqxCCr3DVENKX8DO09hXABAw/JLNJok CsVMAmfo2Fni7K6y50cN02Ugq2ovrbB42Ywz9O76D7yaaknf6gaaitOdJ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="398227644" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="398227644" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 10:52:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="626255713" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="626255713" Received: from jeblanco-mobl.amr.corp.intel.com (HELO tzanussi-mobl1.hsd1.il.comcast.net) ([10.212.118.26]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 10:52:29 -0800 From: Tom Zanussi <tom.zanussi@linux.intel.com> To: herbert@gondor.apana.org.au, davem@davemloft.net, fenghua.yu@intel.com, vkoul@kernel.org Cc: dave.jiang@intel.com, tony.luck@intel.com, wajdi.k.feghali@intel.com, james.guilford@intel.com, kanchana.p.sridhar@intel.com, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, dmaengine@vger.kernel.org Subject: [PATCH 00/16] crypto: Add Intel Analytics Accelerator (IAA) crypto compression driver Date: Mon, 6 Mar 2023 12:52:10 -0600 Message-Id: <20230306185226.26483-1-tom.zanussi@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759646926024857259?= X-GMAIL-MSGID: =?utf-8?q?1759646926024857259?= |
Series |
crypto: Add Intel Analytics Accelerator (IAA) crypto compression driver
|
|
Message
Tom Zanussi
March 6, 2023, 6:52 p.m. UTC
This series adds Linux crypto algorithm support for Intel® In-memory Analytics Accelerator (Intel IAA) [1] hardware compression and decompression, which is available on Sapphire Rapids systems. The IAA crypto support is implemented as an IDXD sub-driver. The IDXD driver already present in the kernel provides discovery and management of the IAA devices on a system, as well as all the functionality needed to manage, submit, and wait for completion of work executed on them. The first 7 patches (patches starting with dmaengine:) add small bits of underlying IDXD plumbing needed to allow external sub-drivers to take advantage of this support and claim ownership of specific IAA devices and workqueues. The remaining patches add the main support for this feature via the crypto API, making it transparently accessible to kernel features that can make use of it such as zswap and zram (patches starting with crypto – iaa:). These include both sync/async support for the deflate algorithm implemented by the IAA hardware, as well as an additional option for driver statistics and Documentation. Patch 8 ('[PATCH 08/16] crypto: iaa - Add IAA Compression Accelerator Documentation') describes the IAA crypto driver in detail; the following is just a high-level synopsis meant to aid the following discussion. The IAA hardware is fairly complex and generally requires a knowledgeable administrator with sufficiently detailed understanding of the hardware to set it up before it can be used. As mentioned in the Documentation, this typically requires using a special tool called accel-config to enumerate and configure IAA workqueues, engines, etc, although this can also be done using only sysfs files. The operation of the driver mirrors this requirement and only allows the hardware to be accessed via the crypto layer once the hardware has been configured and bound to the the IAA crypto driver. As an IDXD sub-driver, the IAA crypto driver essentially takes ownership of the hardware until it is given up explicitly by the administrator. This occurs automatically when the administrator enables the first IAA workqueue or disables the last one; the iaa_crypto (sync and async) algorithms are registered when the first workqueue is enabled, and deregistered when the last one is disabled. The normal sequence of operations would normally be: < configure the hardware using accel-config or sysfs > < configure the iaa crypto driver (see below) > < configure the subsystem e.g. zswap/zram to use the iaa_crypto algo > < run the workload > There are a small number of iaa_crypto driver attributes that the administrator can configure, and which also need to be configured before the algorithm is enabled: compression_mode: The IAA crypto driver supports an extensible interface supporting any number of different compression modes that can be tailored to specific types of workloads. These are implemented as tables and given arbitrary names describing their intent. There are currently only 2 compression modes, “canned” and “fixed”. In order to set a compression mode, echo the mode’s name to the compression_mode driver attribute: echo "canned" > /sys/bus/dsa/drivers/crypto/compression_mode There are a few other available iaa_crypto driver attributes (see Documentation for details) but the main one we want to consider in detail for now is the ‘sync_mode’ attribute. The ‘sync_mode’ attribute has 3 possible settings: ‘sync’, ‘async’, and ‘async_irq’. The context for these different modes is that although the iaa_crypto driver implements the asynchronous crypto interface, the async interface is currently only used in a synchronous way by facilities like zswap that make use of it. This is fine for software compress/decompress algorithms, since there’s no real benefit in being able to use a truly asynchronous interface with them. This isn’t the case, though, for hardware compress/decompress engines such as IAA, where truly asynchronous behavior is beneficial if not completely necessary to make optimal use of the hardware. The IAA crypto driver ‘sync_mode’ support should allow facilities such as zswap to ‘support async (de)compression in some way [2]’ once they are modified to actually make use of it. When the ‘async_irq’ sync_mode is specified, the driver sets the bits in the IAA work descriptor to generate an irq when the work completes. So for every compression or decompression, the IAA acomp_alg implementations called by crypto_acomp_compress/decompress() simply set up the descriptor, turn on the 'request irq' bit and return immediately with -EINPROGRESS. When the work completes, the irq fires and the IDXD driver’s irq thread for that irq invokes the callback the iaa_crypto module registered with IDXD. When the irq thread gets scheduled, it wakes up the caller, which could be for instance zswap, waiting synchronously via crypto_wait_req(). Using the simple madvise test program in '[PATCH 09/17] crypto: iaa - Add IAA Compression Accelerator Documentation' along with a set of pages from the spec17 benchmark and tracepoint instrumentation measuring the time taken between the start and end of each compress and decompress, this case, async_irq, takes on average 6,847 ns for compression and 5,840 ns for decompression. (See Table 1 below for a summary of all the tests.) When sync_mode is set to ‘sync’, the interrupt bit is not set and the work descriptor is submitted in the same way it was for the previous case. In this case the call doesn’t return but rather loops around waiting in the iaa_crypto driver’s check_completion() function which continually checks the descriptor’s completion bit until it finds it set to ‘completed’. It then returns to the caller, again for example zswap waiting in crypto_wait_req(). From the standpoint of zswap, this case is exactly the same as the previous case, the difference seen only in the crypto layer and the iaa_crypto driver internally; from its standpoint they’re both synchronous calls. There is however a large performance difference: an average of 3,177 ns for compress and 2,235 ns for decompress. The final sync_mode is ‘async’. In this case also the interrupt bit is not set and the work descriptor is submitted, returning immediately to the caller with -EINPROGRESS. Because there’s no interrupt set to notify anyone when the work completes, the caller needs to somehow check for work completion. Because core code like zswap can’t do this directly by for example calling iaa_crypto’s check_completion(), there would need to be some changes made to code like zswap and the crypto layer in order to take advantage of this mode. As such, there are no numbers to share for this mode. Finally, just a quick discussion of the remaining numbers in Table 1, those comparing the iaa_crypto sync and async irq cases to software deflate. Software deflate took average of 108,978 ns for compress and 14,485 ns for decompress. As can be seen from Table 1, the numbers using the iaa_crypto driver for deflate as compared to software are so much better that merging it would seem to make sense on its own merits. The 'async' sync_mode described above, however, offers the possibility of even greater gains to be had against higher-performing algorithms such as lzo, via parallelization, once the calling facilities are modified to take advantage of it. Follow-up patchsets to this one will demonstrate concretely how that might be accomplished. Thanks, Tom Table 1. Zswap latency and compression numbers (in ns): Algorithm compress decompress ---------------------------------------------------------- iaa sync 3,177 2,235 iaa async irq 6,847 5,840 software deflate 108,978 14,485 [1] https://cdrdv2.intel.com/v1/dl/getContent/721858 [2] https://lore.kernel.org/lkml/20201107065332.26992-1-song.bao.hua@hisilicon.com/ Dave Jiang (2): dmaengine: idxd: add wq driver name support for accel-config user tool dmaengine: idxd: add external module driver support for dsa_bus_type Tom Zanussi (14): dmaengine: idxd: Export drv_enable/disable and related functions dmaengine: idxd: Export descriptor management functions dmaengine: idxd: Export wq resource management functions dmaengine: idxd: Add private_data to struct idxd_wq dmaengine: idxd: add callback support for iaa crypto crypto: iaa - Add IAA Compression Accelerator Documentation crypto: iaa - Add Intel IAA Compression Accelerator crypto driver core crypto: iaa - Add per-cpu workqueue table with rebalancing crypto: iaa - Add compression mode management along with fixed mode crypto: iaa - Add support for iaa_crypto deflate compression algorithm crypto: iaa - Add support for default IAA 'canned' compression mode crypto: iaa - Add support for iaa_crypto async deflate compression algorithm crypto: iaa - Add irq support for the crypto async interface crypto: iaa - Add IAA Compression Accelerator stats .../ABI/stable/sysfs-driver-dma-idxd | 6 + .../driver-api/crypto/iaa/iaa-crypto.rst | 743 ++++++ Documentation/driver-api/crypto/iaa/index.rst | 20 + Documentation/driver-api/crypto/index.rst | 20 + Documentation/driver-api/index.rst | 1 + drivers/crypto/Kconfig | 1 + drivers/crypto/Makefile | 1 + drivers/crypto/iaa/Kconfig | 19 + drivers/crypto/iaa/Makefile | 12 + drivers/crypto/iaa/iaa_crypto.h | 171 ++ drivers/crypto/iaa/iaa_crypto_comp_canned.c | 110 + drivers/crypto/iaa/iaa_crypto_comp_fixed.c | 92 + drivers/crypto/iaa/iaa_crypto_main.c | 2086 +++++++++++++++++ drivers/crypto/iaa/iaa_crypto_stats.c | 271 +++ drivers/crypto/iaa/iaa_crypto_stats.h | 58 + drivers/dma/idxd/bus.c | 6 + drivers/dma/idxd/cdev.c | 8 + drivers/dma/idxd/device.c | 9 +- drivers/dma/idxd/dma.c | 9 +- drivers/dma/idxd/idxd.h | 74 +- drivers/dma/idxd/irq.c | 12 +- drivers/dma/idxd/submit.c | 9 +- drivers/dma/idxd/sysfs.c | 28 + include/uapi/linux/idxd.h | 1 + 24 files changed, 3747 insertions(+), 20 deletions(-) create mode 100644 Documentation/driver-api/crypto/iaa/iaa-crypto.rst create mode 100644 Documentation/driver-api/crypto/iaa/index.rst create mode 100644 Documentation/driver-api/crypto/index.rst create mode 100644 drivers/crypto/iaa/Kconfig create mode 100644 drivers/crypto/iaa/Makefile create mode 100644 drivers/crypto/iaa/iaa_crypto.h create mode 100644 drivers/crypto/iaa/iaa_crypto_comp_canned.c create mode 100644 drivers/crypto/iaa/iaa_crypto_comp_fixed.c create mode 100644 drivers/crypto/iaa/iaa_crypto_main.c create mode 100644 drivers/crypto/iaa/iaa_crypto_stats.c create mode 100644 drivers/crypto/iaa/iaa_crypto_stats.h
Comments
On Mon, Mar 06, 2023 at 12:52:10PM -0600, Tom Zanussi wrote: > This series adds Linux crypto algorithm support for Intel® In-memory > Analytics Accelerator (Intel IAA) [1] hardware compression and > decompression, which is available on Sapphire Rapids systems. I haven't reviewed the patches yet, but could you please create a drivers/crypto/intel directory and put this driver in it? Thanks,
Hi Herbert, On Tue, 2023-03-07 at 12:20 +0800, Herbert Xu wrote: > On Mon, Mar 06, 2023 at 12:52:10PM -0600, Tom Zanussi wrote: > > This series adds Linux crypto algorithm support for Intel® In- > > memory > > Analytics Accelerator (Intel IAA) [1] hardware compression and > > decompression, which is available on Sapphire Rapids systems. > > I haven't reviewed the patches yet, but could you please create > a drivers/crypto/intel directory and put this driver in it? Sure, I'll respin and move it there. Thanks, Tom > > Thanks,
On 3/6/23 9:20 PM, Herbert Xu wrote: > On Mon, Mar 06, 2023 at 12:52:10PM -0600, Tom Zanussi wrote: >> This series adds Linux crypto algorithm support for Intel® In-memory >> Analytics Accelerator (Intel IAA) [1] hardware compression and >> decompression, which is available on Sapphire Rapids systems. > > I haven't reviewed the patches yet, but could you please create > a drivers/crypto/intel directory and put this driver in it? Hi Herbert, does this mean drivers/crypto/qat should now move to drivers/crypto/intel/qat? > > Thanks,
On Tue, Mar 07, 2023 at 08:54:03AM -0700, Dave Jiang wrote: > > Hi Herbert, does this mean drivers/crypto/qat should now move to > drivers/crypto/intel/qat? Yes we should move qat as well. Oh and there's also ixp4xx and keembay. Thanks,