From patchwork Wed Nov 6 19:21:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchana P Sridhar X-Patchwork-Id: 13865327 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 CAED6D59F6A for ; Wed, 6 Nov 2024 19:21:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9998E6B009F; Wed, 6 Nov 2024 14:21:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 949C26B00A1; Wed, 6 Nov 2024 14:21:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79E726B00A0; Wed, 6 Nov 2024 14:21:21 -0500 (EST) 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 53CF96B009E for ; Wed, 6 Nov 2024 14:21:21 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0FA1D121D6E for ; Wed, 6 Nov 2024 19:21:21 +0000 (UTC) X-FDA: 82756638006.18.06FE1D6 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by imf18.hostedemail.com (Postfix) with ESMTP id 740231C0010 for ; Wed, 6 Nov 2024 19:21:03 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nkoFg+fu; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.11 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=1730920795; 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=A2OQWF+jRt4/xufhX9UbIWAE7obRnbYO4ug11BP+78o=; b=NWYQIBF5sSZl/6C9rMt5JBixfe+v5Iyee91xdXpw5AHoC2qazKw/9J9A6MVXT2NET/cX8P 4VFy89cecybXalsMbEIFdHzXn5LB0tGdTfXioZCc2mQBIwP4Qk1YPhXEiqIuv45Ysf9K3k gv9GQDYSU0oax4FmIplBdwmsaGYaQXQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nkoFg+fu; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730920795; a=rsa-sha256; cv=none; b=dC4IP/6XkF7zbNg5gPFKBwXNFAMBi8fw3d52qV4EnJzKA+YGxNDGu2Ys/clgMd3tDQbF7y bkdYK47J/nVivM+clQfYz6OBA4FNceY2Bv8qrSP6wl3UBSptVrnHv9s9/ViHb0kTEtRM2Y gqE6sIxYt24Hn4zvCdKnfEOli9V8snU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730920879; x=1762456879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RvYO56c7H8o1E9i8DrptIuQN+cu6z6PTo04ljSRvTjY=; b=nkoFg+fucaBR4Shhlmb1ouckZNRwFMqspFu8Cb/yFzUjRM0FvLOK5iki YzqhF5pKwjzC4uCD7kvDhIgm6RQvwa6tZABc509JlT8Oq31y0wb/ZCHVD ksG0yMy2mdrBZnDaU1pb+APcbx2phVHp5PXABuJeUo9CqC0QXdPsHFBRW 82cxEnE76UwZR4sY4+rB/GaVne4cFhXXWJMg8S/B891qklvGqhNuM8sPG YUPRIZDmi1CQzANvvGQ012gqNcAOuMh+E7kBCqnWF7sLLYcYK+qunvwqB HFS1xJ3ng0kNDtUePOyyppUqLpmsxvJU2KHyx+6DcxBkEPRxzwxXmQx6u Q==; X-CSE-ConnectionGUID: Ey3+d9h9QAGVSvsjThkjSA== X-CSE-MsgGUID: 0wpcc7TSQFyD/DLFg++e7Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="41292074" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="41292074" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 11:21:14 -0800 X-CSE-ConnectionGUID: nN2+UNtXTT6rc/74ttu3rw== X-CSE-MsgGUID: KjGO/gTnShy76yRTS9Bp3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,263,1725346800"; d="scan'208";a="88695422" Received: from unknown (HELO JF5300-B11A338T.jf.intel.com) ([10.242.51.115]) by fmviesa003.fm.intel.com with ESMTP; 06 Nov 2024 11:21:13 -0800 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 Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v3 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout. Date: Wed, 6 Nov 2024 11:21:04 -0800 Message-Id: <20241106192105.6731-13-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241106192105.6731-1-kanchana.p.sridhar@intel.com> References: <20241106192105.6731-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 740231C0010 X-Stat-Signature: inu5oap15h5jx6tmbfy4oyb4ue1gjg4t X-HE-Tag: 1730920863-168357 X-HE-Meta: U2FsdGVkX1/vPAFKmTK2Tba22gdnpsg1f+q58mL85zzZ9XEssA3GMdYDcmWKS2b6fdG9r/60gTwfrvbh1B1Tp0d42rN+PWN3J6jfYO4FeDvblfTsWXyig7ObqLwDIYyvZGwKeWhToZagoIpLl/P7RHSi3EhkeCfjHrWCrINKU2ekPLFV2BPsjtuX79kxe+NHq8PqKHziFmVBouf7ir2DZmMedR1MQ4kirvfP9rOAmVN3upyO8SccYVFWvoVLloRIMTNUbBTYL3r1XAG4OAQyaJ3lpdfPY/OrkNJvIytKu4hg39ePvkcvncQiehVztVudMefY9zrnZB68yZuTEi/oibm8LLGFtzEct7DWQrYe5H8mxVJ+qKs2ZZB9/BBw3TailBZqD9/cTiVgjTDwNMzOa0Kw595wXC6by6RNUIgrQSW8kDYd7YV2JkXZQcqIJ212eHEOPjV9eSpDZgkp5Djg42ppHZJGmH3zxphPHm90FRcwbe5P1a7kPSbScSL3GjgwdI0LWOSZ6jiPbCeYMwMWYARpdQ5xZ80dDxVWWZlLi5D22q6UM3x19ZwEdgeRBP82AD5g4/gxsskXzNTj5YQski2lB1OpynczxiHSO61pZAB4Syh4fgASFvLqE757dlYjha3Ie4q6ZxZ9YDWlQrKDxoUtg7CZLPO3NfXWFVwFne7k/KijprzaWEMVGwN7Ycpdd/GWJSHZJrEeRnxGeKels4S2RF77ZxsUlR2bMq0IPyB4eXsIWmGyx7lbBwzRsZW4m2FFIsHYK7LPvjt7Th3nZrV4Da6DEp+b3c0znjdADTqXRdoPc8vbfixcmDZwbq2XvOMc1xtG0CMuytsxPnUJYK2AmuVfYdlbXvPu8U5netTqd59+sK6yruOybaKBHt6BMBcUGx4LCxuMFzK/MRccX88SUef+aN6xshi9qq2hHNNwFZf2VB4u58pETHJwOS+aeA3LPw0G2mv3cEYo8Fp VKPBJrks V/CgeN2zw2FvUc8sZuYdewWuVOFmTZ022wf4b4eINgJgiGxunQtQZ/eK4/MZ7GVQXXpqsK+RMsOxQhzeYEOn2GuCZPuBxdCPq+jjGSqm/HjImZsDhkFpA7UMpcREXiHUcf6Edyohh3L4p17tUAXZRLfLHYyCzLpgdKd3xRgvmjXUd/nJnOqb6hedXkQ== 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: The sysctl vm.compress-batching parameter is 0 by default. If the platform has Intel IAA, the user can run experiments with IAA compress batching of large folios in zswap_store() as follows: sysctl vm.compress-batching=1 echo deflate-iaa > /sys/module/zswap/parameters/compressor This is expected to significantly improve zswap_store() latency of swapping out large folios due to parallel compression of 8 pages in the large folio at a time, in hardware. Setting vm.compress-batching to "1" takes effect only if the zswap compression algorithm's crypto_acomp registers implementations for the batch_compress() and batch_decompress() API. In other words, compress batching works only with the iaa_crypto driver, that does register these new batching API. It is a no-op for compressors that do not register the batching API. The sysctl vm.compress-batching acts as a switch because it takes effect upon future zswap_store() calls on any given core. If the switch is "1", large folios will use parallel batched compression of the folio's pages. If the switch is "0", zswap_store() will use sequential compression for storing every page in a large folio. Signed-off-by: Kanchana P Sridhar --- include/linux/mm.h | 2 ++ kernel/sysctl.c | 9 +++++++++ mm/swap.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index fecd47239fa9..f61915aa2f37 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -82,8 +82,10 @@ extern const int page_cluster_max; #ifdef CONFIG_SYSCTL extern int sysctl_legacy_va_layout; +extern unsigned int compress_batching; #else #define sysctl_legacy_va_layout 0 +#define compress_batching 0 #endif #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 79e6cb1d5c48..e298857595b4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2064,6 +2064,15 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = (void *)&page_cluster_max, }, + { + .procname = "compress-batching", + .data = &compress_batching, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_douintvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, diff --git a/mm/swap.c b/mm/swap.c index 638a3f001676..bc4c9079769e 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -47,6 +47,9 @@ int page_cluster; const int page_cluster_max = 31; +/* Enable/disable compress batching during swapout. */ +unsigned int compress_batching; + struct cpu_fbatches { /* * The following folio batches are grouped together because they are protected @@ -1074,4 +1077,7 @@ void __init swap_setup(void) * Right now other parts of the system means that we * _really_ don't want to cluster much more */ + + /* Disable compress batching during swapout by default. */ + compress_batching = 0; }