From patchwork Sun Nov 3 03:21:10 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: 13860297 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 CBA6DE6781A for ; Sun, 3 Nov 2024 03:21:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 436B66B009D; Sat, 2 Nov 2024 23:21:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BE076B009F; Sat, 2 Nov 2024 23:21:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 210ED6B009E; Sat, 2 Nov 2024 23:21:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ECCF56B009C for ; Sat, 2 Nov 2024 23:21:27 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7864780D61 for ; Sun, 3 Nov 2024 03:21:27 +0000 (UTC) X-FDA: 82743332490.10.2F44D9A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by imf17.hostedemail.com (Postfix) with ESMTP id 184694000E for ; Sun, 3 Nov 2024 03:21:01 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SLtMYW5I; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf17.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 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=1730604003; 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=s6LLDw37i5cu+HINgWP4vPH/p7itmhc/p8xNggw8EKo=; b=e/9+vfxOSzPU4Nc7LpfDkjKdPnux4fTtHLMb1EFuB6qR1QA9C8RBHa0dixpb0THS0beVUv oTEbxO+/QpiLQ81w4+665Ow30ZUFSBHQ18sLweWHDOa1ZjCq4AEvKguAwy1Wum4ZZutkK9 Ydi2yhJC1tRFOsVw0NlY4/qnT/jYbYo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SLtMYW5I; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf17.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.14 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730604003; a=rsa-sha256; cv=none; b=wuaMculDIMrv5YtdOg+JV1TMxBWd5dSPCQnVzon41Obx+C8w4onlOFD9xG8lm/n20Pl7WS +bQBdvE2aAeI+9ZwaTnY6iknY4ojMNWtFcq7Iaoad++KKJ8/1GrgYtKOg6cQDXe4QmFqyR UatE/HHs6Kf6skBPLql4v+JnRe7vosA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730604085; x=1762140085; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LRgON0J+B8CkVFIt5Q3iyXtNXhdwK4RCB9NPlp2lvok=; b=SLtMYW5IYRIa3npfuAmejcxeoKmD9w+hgErdMm3YmYm4lC1r4J0aiEk5 zHd1Y+kTUEPbLicK5kj/CCmatX43scQl4zbCitaaXMFMNzYxbcu2Gk1ve DP7E3yLtKGXGtJC/rkgvkr/chEuYxr1gAEmX/eqVGCiQctWArwf5t6zB0 y8txWY8r9i98ZXYI10B4+v1b/t1vGQDDevNMgXblVuBCO1Ihg1gThjmA1 L+sXNIJsAzH9swqK4q3KWO52UM7BygiFqu4J5HvHL1PixcDn4spTfuvX+ cIZMNuqMs9DH/Ah+FiBz11XABJbh5JBXDXRg0F5FdKNi+s3FNXPXj2JlA A==; X-CSE-ConnectionGUID: B1n2JjDXSkWTnxaiptkTLA== X-CSE-MsgGUID: Y/J37debTu67SWzDWPxvGA== X-IronPort-AV: E=McAfee;i="6700,10204,11244"; a="30548357" X-IronPort-AV: E=Sophos;i="6.11,254,1725346800"; d="scan'208";a="30548357" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2024 20:21:14 -0700 X-CSE-ConnectionGUID: Vry+ngz1T2CnvIoMfXY38w== X-CSE-MsgGUID: NSoSHThITDqKrhfED8nBYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,254,1725346800"; d="scan'208";a="83451906" Received: from unknown (HELO JF5300-B11A338T.jf.intel.com) ([10.242.51.115]) by orviesa006.jf.intel.com with ESMTP; 02 Nov 2024 20:21:15 -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 Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout. Date: Sat, 2 Nov 2024 20:21:10 -0700 Message-Id: <20241103032111.333282-13-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241103032111.333282-1-kanchana.p.sridhar@intel.com> References: <20241103032111.333282-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 184694000E X-Stat-Signature: i5qdpyjjb9u3wph8try6xxtb5ub4k4ux X-HE-Tag: 1730604061-804772 X-HE-Meta: U2FsdGVkX18/u5+vbpJLA6l5c93DHhlNb3ReaysIw+hT26W8aDnLbAPO41S84deYfdzcWZ4Gb112TcfSWqBeS9RlRtN+64Q/iOmGyvJbkCLG2yMBnZowAg4HE2at+2SiDZ7Lih7kpgBSm6epIdBKMw95Ic93ZfWOe/w6crcLKCHNAj+sT8AcUM+ljCT9eJnGuWBBRI72NRASFEdySoiUqDaGJsyEkpG8B+805Uhz7df5PzYo1JFJMQ0nmQOsTUTXlVyt+eqcqznATcwHIb6/wN8WeZDL7cH/OMg05jCsgyjJU/ayexdVDd/JIVe0wqvz6QS2QCZ3hqEPm9/ob5XDzJB/olPbVDldsjN3qiNFzLXb+4wG0XQvnmJpnJBNlaz/zvTI/B64ujQrPq5WrDVmQ0zvIbdlolxF8P3gU6sB8ZjmPA+36KS1KYkeVVp9wy/RxjcR397zJl/WSR6OFYtxK79hzwmZGAUMVPkHDjHiZ2VTrtlg5iwcvu1knNW+uhD54F5UO9maJecVoVWzNxSp9k1R9G5OaYtfdbLhWdrz9SPQDiC6nGx5A2YaxMz2Tdo7bk/v7j2ZdqonMy6u5Y18+bthf3Tn/D19laJYrYATAXuKKcVUEdGOKxXvgKIF0jJAZrAJJ0/HKpgV4j/SWY3MpzZo1egSAi7IpcAMPrqb0GIPOOpm5rUZaSUj6Ya1apXfj+rChuEz1kTUzGPSJhpcBeOy4inKG+wwbpD/WIdr5CBf8kV9hTwd+mIJiEU+bJ7yDQxS5uv21x9o8KZu5Na0bKw2cOarT9Eb8jLYrTfBmois1HUieU7bBLVCeVSldBzTtvC6rtZfaCHweuARgRsMb8UNov8tgB+26kk4SaNcp+p8c3hwwdEdrzCcmx9O3GFs/riKGdVkPWaemzloKyXWB/CnlI9snYTidJ8/XYXWrEK3MPMzG51gcUt9k8CHeyU0L+CVQKncUw0rc5gfUbY hj664uNN IZWMh9iT5VnonEp7h5Dmg42D3qllkauzu02IuRWSGVLrfGJ823DlPLQpK3KvgR79N1Siq5/r6cCHtywmZBMU/nq/GDP5MWvaGDkAyLkG3+G+PKE2IBXlSXL77i67P6mDzA2EixO6A5BJYI3Dv5TK+UwD9MLlQOA9P7LCuhGkxsmvybJ+jn4pd8xCl6A== 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 610653a8b0fe..c94ba5c36169 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; }