From patchwork Fri Oct 18 06:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13841236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20DB4D3C550 for ; Fri, 18 Oct 2024 06:41:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2D9A6B0099; Fri, 18 Oct 2024 02:41:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB4736B009C; Fri, 18 Oct 2024 02:41:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94466B009D; Fri, 18 Oct 2024 02:41:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7F51C6B0099 for ; Fri, 18 Oct 2024 02:41:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 155A31C6F67 for ; Fri, 18 Oct 2024 06:41:00 +0000 (UTC) X-FDA: 82685775690.26.FF38FE7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by imf27.hostedemail.com (Postfix) with ESMTP id 6686440008 for ; Fri, 18 Oct 2024 06:41:00 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=eridgetG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.15 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729233552; a=rsa-sha256; cv=none; b=hXDeHAugcq8SPhaJ5YOQdh+DLcxee/RbIZedgOyYbgYxvawhsDaQ6b+UrPjqI33xCUU4oU TFHelwHBzdrlD40KJ3oqtdKbef7Nag7/jraxae08eVcB9+yfz10cEiXR0V7LkX2XW24dar C6TGaQAdDS9kOYEWRvYRk00w6WSFqo0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=eridgetG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.15 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729233552; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1cCwxHrWTh0Fjc9IYlgOU3POgtAU1eNjfTY1o6LL8NI=; b=Rov+elM/hmUikohRvXkPN/fYHDoTxgItVDXmrksFb7pQPjAGoPmRPbT/+BtmGYOBN8VALe 4//C7K5HLgv92Mz58ortmfK0mZ+cG/IgvLkrnodzFknxM988GHUrVyhS3SwDa8ALXRqTQS 9C3+oyrGjdqkEbIsvzxU+P4DSr5XYy4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729233671; x=1760769671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qqxb4WHT8bprxcMFQO92c1NKetq9casrAYfBRMVL0vQ=; b=eridgetGJ+xcJU/tRREy2BvT+D40sHScrtyK3oQ4G1w/xaO3zlL450H0 qEPUuhS+PW4OhlO9T5IOIhrjTSC6PZ6tyZ9Sbpv6qrDfzCtbpIdpws7bA /bxBic4nIJAt3HzldjQdivB7My3KDuXWYG0Xcx5DXq3URpIA43Xj1FDck ylTUXjn6FxDpwLr/FM7f4qDezwEtoQkQfJwSM2RbE+s/kQ4nj8SLp4kK/ hMLy/lBxgQA4x5AQ0PhL6A219Y3ZuZwqClRdmqb/HEgKlzm87+LPCH2/A JF26O4qUImqW8Mbd7tvRkp/siONs56XfRwcibKBBhtI8Ao8ex6oGCs67f Q==; X-CSE-ConnectionGUID: Zz0Bvj+OQ1SfyN2HnCP6bA== X-CSE-MsgGUID: PW3nBt7CSbuydBlug38cgw== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="28884910" X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="28884910" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 23:41:03 -0700 X-CSE-ConnectionGUID: KzCXCTJiQFKm7BYr/a601A== X-CSE-MsgGUID: e8EgEA8oSM6ZXNXDpKJJHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="83607525" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa003.jf.intel.com with ESMTP; 17 Oct 2024 23:41:03 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, clabbe@baylibre.com, ardb@kernel.org, ebiggers@google.com, surenb@google.com, kristen.c.accardi@intel.com, zanussi@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, mcgrof@kernel.org, kees@kernel.org, joel.granados@kernel.org, bfoster@redhat.com, willy@infradead.org, linux-fsdevel@vger.kernel.org Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [RFC PATCH v1 09/13] mm: zswap: Config variable to enable compress batching in zswap_store(). Date: Thu, 17 Oct 2024 23:40:57 -0700 Message-Id: <20241018064101.336232-10-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241018064101.336232-1-kanchana.p.sridhar@intel.com> References: <20241018064101.336232-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6686440008 X-Stat-Signature: b5fe4n3nipxmj44g3pnf6jyxp1je45ht X-Rspam-User: X-HE-Tag: 1729233660-59886 X-HE-Meta: U2FsdGVkX19NQ3FgCUug6Zj3n8SFhNCqf7dY1e0K0WOXbdr77OjVmkK5DdkEJruuUjgYPodYLLmLLWXTVdW2dqr9YWkSHwqFJ5oQ4fpPt+/RGLW/P4HtD2khJDYAHGxlp+7gbwD2y1UBljwenWg19ljAyf8UC2ntde2AjeuESbkW/C3JGQHVVnWS0AGxWl6OQQNaTBW4Vfj3W+ubRtO1f1ZsRMjLXQyBQ3mlrP7sqghjnKpKAFdc7hAmEajSHJdISGQOiT5xinToMVWqNcY0S6gAVufOwEH5H1XMNkBt6PBfuczWXbd1g88tlsHsKGyea0aOBINVLd7Qmb7r+FaKLzAT2NsC0thI1V4al86s05U52KbNHrObWRaDyAoOLpGGwmSoiachPZPfBC0XxfrB2n/P5Ozh7ghEhr8IBlLRk4q2DDB/PeuYyl5KCWN9T81ldIPH662M/l1PC0D+dt6TTkw9R10kAsHMGSu5apZLVcp4vmgdRkxi7EbsedDYGcVfcR60n80wl7Rww7x3aflweGGe7ci7AFq/tzeTP9ZR3VjfKyXqOjr0N7VRScxMfvcKVwfytK++uMELdlYrhDy4orJFybF3WBtaYYH7C6x2/LCrFAVWKD8j+swYRla4FDaCTPPaz+Cvmg51C8Wc7/aOYaf8K45cL8nax2wOjNVBQxju8gbMil3kA2dZeTno2vzTykgncqhe63GO5LMM+b8NJbT12Yedevav1DM9zUwrRJO9h8z+mpPmA/kMiWGbcqbtg5VD75B7xms7/UU84+wVRfJuClBWlnHgQzbF1q1fTusETncvxoeb5teW5hG57oxu8p9joZI4qHHylD8Wd5H6N+NA1KBbTsMInbrRss+BclKFixX4De9sTWuA44XO8DZbqgYE1IiNqQoSefFcm6ZPsUEzRiApygbdPdvd/QaTSe+jTgBnL7pGAlgRKvbobYRT1/kUPJaI4IcagNNaFUB Nx6TrGpC 6c8nuBsT8448FEJJecOV1A6CpXfzdJjsT53wWGaFbWjyIbVSUq3G6YRScO0OAmp0ieivNX5s7JzPF7+3reViUhmH9YxLC/UGpWye18g9nC2EBW7MpG85JfKKVeXw9AN5jW0wHAONKfLoZ6R6wMTlLmJZbpIRJ1yW5YsiMahRNM9/lS0idpASGFEjlNFVPZ8SriGURXpyKDm2F7/30pmns/QHOHpffkGGjeONE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a new zswap config variable that controls whether zswap_store() will compress a batch of pages, for instance, the pages in a large folio: CONFIG_ZSWAP_STORE_BATCHING_ENABLED The existing CONFIG_CRYPTO_DEV_IAA_CRYPTO variable added in commit ea7a5cbb4369 ("crypto: iaa - Add Intel IAA Compression Accelerator crypto driver core") is used to detect if the system has the Intel Analytics Accelerator (IAA), and the iaa_crypto module is available. If so, the kernel build will prompt for CONFIG_ZSWAP_STORE_BATCHING_ENABLED. Hence, users have the ability to set CONFIG_ZSWAP_STORE_BATCHING_ENABLED="y" only on systems that have Intel IAA. If CONFIG_ZSWAP_STORE_BATCHING_ENABLED is enabled, and IAA is configured as the zswap compressor, zswap_store() will process the pages in a large folio in batches, i.e., multiple pages at a time. Pages in a batch will be compressed in parallel in hardware, then stored. On systems without Intel IAA and/or if zswap uses software compressors, pages in the batch will be compressed sequentially and stored. The patch also implements a zswap API that returns the status of this config variable. Suggested-by: Ying Huang Signed-off-by: Kanchana P Sridhar --- include/linux/zswap.h | 6 ++++++ mm/Kconfig | 12 ++++++++++++ mm/zswap.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/include/linux/zswap.h b/include/linux/zswap.h index d961ead91bf1..74ad2a24b309 100644 --- a/include/linux/zswap.h +++ b/include/linux/zswap.h @@ -24,6 +24,7 @@ struct zswap_lruvec_state { atomic_long_t nr_disk_swapins; }; +bool zswap_store_batching_enabled(void); unsigned long zswap_total_pages(void); bool zswap_store(struct folio *folio); bool zswap_load(struct folio *folio); @@ -39,6 +40,11 @@ bool zswap_never_enabled(void); struct zswap_lruvec_state {}; +static inline bool zswap_store_batching_enabled(void) +{ + return false; +} + static inline bool zswap_store(struct folio *folio) { return false; diff --git a/mm/Kconfig b/mm/Kconfig index 33fa51d608dc..26d1a5cee471 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -125,6 +125,18 @@ config ZSWAP_COMPRESSOR_DEFAULT default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD default "" +config ZSWAP_STORE_BATCHING_ENABLED + bool "Batching of zswap stores with Intel IAA" + depends on ZSWAP && CRYPTO_DEV_IAA_CRYPTO + default n + help + Enables zswap_store to swapout large folios in batches of 8 pages, + rather than a page at a time, if the system has Intel IAA for hardware + acceleration of compressions. If IAA is configured as the zswap + compressor, this will parallelize batch compression of upto 8 pages + in the folio in hardware, thereby improving large folio compression + throughput and reducing swapout latency. + choice prompt "Default allocator" depends on ZSWAP diff --git a/mm/zswap.c b/mm/zswap.c index 948c9745ee57..4893302d8c34 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -127,6 +127,15 @@ static bool zswap_shrinker_enabled = IS_ENABLED( CONFIG_ZSWAP_SHRINKER_DEFAULT_ON); module_param_named(shrinker_enabled, zswap_shrinker_enabled, bool, 0644); +/* + * Enable/disable batching of compressions if zswap_store is called with a + * large folio. If enabled, and if IAA is the zswap compressor, pages are + * compressed in parallel in batches of say, 8 pages. + * If not, every page is compressed sequentially. + */ +static bool __zswap_store_batching_enabled = IS_ENABLED( + CONFIG_ZSWAP_STORE_BATCHING_ENABLED); + bool zswap_is_enabled(void) { return zswap_enabled; @@ -241,6 +250,11 @@ static inline struct xarray *swap_zswap_tree(swp_entry_t swp) pr_debug("%s pool %s/%s\n", msg, (p)->tfm_name, \ zpool_get_type((p)->zpool)) +__always_inline bool zswap_store_batching_enabled(void) +{ + return __zswap_store_batching_enabled; +} + /********************************* * pool functions **********************************/