zswap-cli - Man Page

command-line tool to control the ZSwap kernel module

Synopsis

zswap-cli [OPTION...]

Description

zswap-cli is a command-line tool to control the ZSwap kernel module.

Features

Supported kernel module options:

NameValueStatusKernel version
enabledY (enable) or N (disable)ActiveAny
same_filled_pages_enabledY (enable) or N (disable)Deprecated4.16.0 to 6.10.0
max_pool_percentinteger from 1 to 100ActiveAny
compressorfrom supported by kernelActiveAny
zpoolfrom supported by kernelActiveAny
accept_threshold_percentinteger from 1 to 100Active5.6.0 or higher
non_same_filled_pages_enabledY (enable) or N (disable)Deprecated5.18.0 to 6.10.0
exclusive_loadsY (enable) or N (disable)Deprecated6.5.0 to 6.9.0
shrinker_enabledY (enable) or N (disable)Active6.8.0 or higher

Deprecated functionality will be removed in future project versions.

Command-Line Options

--help

Print help message and exit.

--version

Print version information and exit.

--config

Get options from the configuration file instead of the cmdline.

--env

Get options from the environment variables instead of the cmdline.

--stats

Get statistics and current settings of the ZSwap kernel module.

Supported values:

  • 0 (default) - print everything: kernel module settings, usage summary, and debug information.
  • 1 - print kernel module settings.
  • 2 - print kernel module usage summary.
  • 3 - print kernel module debug information.

-e, --enabled

Enable or disable the ZSwap kernel module.

Supported values: Y, N.

-s, --same_filled_pages_enabled

Enable or disable memory pages deduplication.

Supported values: Y, N.

-p, --max_pool_percent

The maximum percentage of memory that the compressed pool can occupy.

Supported values: integer from 1 to 100.

-c, --compressor

The algorithm used to compress memory pages.

Supported values: depends on the kernel build time configuration.

-z, --zpool

The kernel’s zpool type.

Supported values: depends on the kernel build time configuration.

-a, --accept_threshold_percent

The threshold at which ZSwap would start accepting pages again after it became full.

Supported values: integer from 1 to 100.

-n, --non_same_filled_pages_enabled

Enable or disable accepting non same filled memory pages.

Supported values: Y, N.

-x, --exclusive_loads

Enable or disable entries invalidation when memory pages are loaded from compressed pool.

Supported values: Y, N.

-r, --shrinker_enabled

Enable or disable pool shrinking based on memory pressure.

Supported values: Y, N.

Environment Options

zswap-cli support of getting options from the environment variables.

Supported options

  • ZSWAP_ENABLED_VALUE - enable or disable the ZSwap kernel module.
  • ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE - enable or disable memory pages deduplication.
  • ZSWAP_MAX_POOL_PERCENT_VALUE - the maximum percentage of memory that the compressed pool can occupy.
  • ZSWAP_COMPRESSOR_VALUE - the algorithm used to compress memory pages.
  • ZSWAP_ZPOOL_VALUE - the kernel’s zpool type.
  • ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE - the threshold at which ZSwap would start accepting pages again after it became full.
  • ZSWAP_NON_SAME_FILLED_PAGES_ENABLED_VALUE - enable or disable accepting non same filled memory pages.
  • ZSWAP_EXCLUSIVE_LOADS_VALUE - enable or disable entries invalidation when memory pages are loaded from compressed pool.
  • ZSWAP_SHRINKER_ENABLED_VALUE - enable or disable pool shrinking based on memory pressure.

Forwarding options

Export the environment variables using the export command:

export ZSWAP_ENABLED_VALUE=Y
export ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE=Y
export ZSWAP_MAX_POOL_PERCENT_VALUE=60
export ZSWAP_COMPRESSOR_VALUE=lzo
export ZSWAP_ZPOOL_VALUE=z3fold
export ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE=90
export ZSWAP_NON_SAME_FILLED_PAGES_ENABLED_VALUE=Y
export ZSWAP_EXCLUSIVE_LOADS_VALUE=Y
export ZSWAP_SHRINKER_ENABLED_VALUE=Y

Start the application with the --env command-line argument:

sudo zswap-cli --env

Note that most distributions are configured by default not to pass user-defined ENV settings when using sudo. In such cases, you can explicitly specify them all in one command:

sudo ZSWAP_ENABLED_VALUE=Y \
     ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE=Y \
     ZSWAP_MAX_POOL_PERCENT_VALUE=60 \
     ZSWAP_COMPRESSOR_VALUE=lzo \
     ZSWAP_ZPOOL_VALUE=z3fold \
     ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE=90 \
     ZSWAP_NON_SAME_FILLED_PAGES_ENABLED_VALUE=Y \
     ZSWAP_EXCLUSIVE_LOADS_VALUE=Y \
     ZSWAP_SHRINKER_ENABLED_VALUE=Y \
     zswap-cli --env

Configuration Files

zswap-cli support of getting options from the configuration files.

Supported options

  • enabled - enable or disable the ZSwap kernel module.
  • same_filled_pages_enabled - enable or disable memory pages deduplication.
  • max_pool_percent - the maximum percentage of memory that the compressed pool can occupy.
  • compressor - the algorithm used to compress memory pages.
  • zpool - the kernel’s zpool type.
  • accept_threshold_percent - the threshold at which ZSwap would start accepting pages again after it became full.
  • non_same_filled_pages_enabled - enable or disable accepting non same filled memory pages.
  • exclusive_loads - enable or disable entries invalidation when memory pages are loaded from compressed pool.
  • shrinker_enabled - enable or disable pool shrinking based on memory pressure.

Forwarding options

Create a configuration file:

[zswap]
enabled=Y
same_filled_pages_enabled=Y
max_pool_percent=60
compressor=lzo
zpool=z3fold
accept_threshold_percent=90
non_same_filled_pages_enabled=Y
exclusive_loads=Y
shrinker_enabled=Y

Start the application with the --config command-line argument:

sudo zswap-cli --config /path/to/zswap-cli.conf

Systemd Unit

After installation, the systemd unit zswap-cli.service will be added.

Changing settings

All settings are stored in the /etc/zswap-cli/zswap-cli.conf configuration file. It uses standard key-value syntax and can be edited by the user.

Enabling unit

Enable the systemd unit to allow it to run at system startup:

sudo systemctl enable --now zswap-cli.service

Disabling unit

Disable the systemd unit and stop it from running at system startup:

sudo systemctl disable zswap-cli.service

Running unit

It is also possible to start the systemd unit without adding it to startup.

Start the unit and enable ZSwap:

sudo systemctl start zswap-cli.service

Stop the unit and disable ZSwap:

sudo systemctl stop zswap-cli.service

Exit Status

0: Successful exit.

1: An error occurred.

Authors

Copyright (c) 2020-2024 EasyCoding Team and contributors.

Info

General Commands Manual