[PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.

Kanchana P Sridhar posted 13 patches 3 weeks ago
There is a newer version of this series
[PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.
Posted by Kanchana P Sridhar 3 weeks ago
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 <kanchana.p.sridhar@intel.com>
---
 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;
 }
-- 
2.27.0
Re: [PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.
Posted by kernel test robot 3 weeks ago
Hi Kanchana,

kernel test robot noticed the following build errors:

[auto build test ERROR on 5c4cf96cd70230100b5d396d45a5c9a332539d19]

url:    https://github.com/intel-lab-lkp/linux/commits/Kanchana-P-Sridhar/crypto-acomp-Define-two-new-interfaces-for-compress-decompress-batching/20241103-112337
base:   5c4cf96cd70230100b5d396d45a5c9a332539d19
patch link:    https://lore.kernel.org/r/20241103032111.333282-13-kanchana.p.sridhar%40intel.com
patch subject: [PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.
config: i386-buildonly-randconfig-002-20241103 (https://download.01.org/0day-ci/archive/20241103/202411031803.xNibgI5N-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241103/202411031803.xNibgI5N-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411031803.xNibgI5N-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from mm/swap.c:17:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from mm/swap.c:26:
   include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      47 |         __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
         |                                    ~~~~~~~~~~~ ^ ~~~
   include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      49 |                                 NR_ZONE_LRU_BASE + lru, nr_pages);
         |                                 ~~~~~~~~~~~~~~~~ ^ ~~~
>> mm/swap.c:51:14: error: expected identifier or '('
      51 | unsigned int compress_batching;
         |              ^
   include/linux/mm.h:88:27: note: expanded from macro 'compress_batching'
      88 | #define compress_batching 0
         |                           ^
>> mm/swap.c:1082:20: error: expression is not assignable
    1082 |         compress_batching = 0;
         |         ~~~~~~~~~~~~~~~~~ ^
   3 warnings and 2 errors generated.


vim +51 mm/swap.c

    49	
    50	/* Enable/disable compress batching during swapout. */
  > 51	unsigned int compress_batching;
    52	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.
Posted by kernel test robot 3 weeks ago
Hi Kanchana,

kernel test robot noticed the following build errors:

[auto build test ERROR on 5c4cf96cd70230100b5d396d45a5c9a332539d19]

url:    https://github.com/intel-lab-lkp/linux/commits/Kanchana-P-Sridhar/crypto-acomp-Define-two-new-interfaces-for-compress-decompress-batching/20241103-112337
base:   5c4cf96cd70230100b5d396d45a5c9a332539d19
patch link:    https://lore.kernel.org/r/20241103032111.333282-13-kanchana.p.sridhar%40intel.com
patch subject: [PATCH v2 12/13] mm: Add sysctl vm.compress-batching switch for compress batching during swapout.
config: m68k-stmark2_defconfig (https://download.01.org/0day-ci/archive/20241103/202411031633.Hlf9Mjxh-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241103/202411031633.Hlf9Mjxh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411031633.Hlf9Mjxh-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from mm/swap.c:17:
>> include/linux/mm.h:88:27: error: expected identifier or '(' before numeric constant
      88 | #define compress_batching 0
         |                           ^
   mm/swap.c:51:14: note: in expansion of macro 'compress_batching'
      51 | unsigned int compress_batching;
         |              ^~~~~~~~~~~~~~~~~
   mm/swap.c: In function 'swap_setup':
>> mm/swap.c:1082:27: error: lvalue required as left operand of assignment
    1082 |         compress_batching = 0;
         |                           ^


vim +88 include/linux/mm.h

    82	
    83	#ifdef CONFIG_SYSCTL
    84	extern int sysctl_legacy_va_layout;
    85	extern unsigned int compress_batching;
    86	#else
    87	#define sysctl_legacy_va_layout 0
  > 88	#define compress_batching 0
    89	#endif
    90	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki