Skip to content

Commit 08dcd2a

Browse files
committed
Better zswap config
1 parent 466c606 commit 08dcd2a

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

include/swap-default.conf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ swap_mode=auto
1616

1717
################################################################################
1818
# Zswap - Compressed RAM cache for swap pages
19-
# Only used when swap_mode=zswap+swapfc or manual with zswap_enabled=1
2019
#
21-
# zswap compresses pages before writing to swap, reducing I/O
22-
# Requires a backing swap device (swap file or partition)
20+
# zswap compresses pages before writing to swap, reducing I/O.
21+
# Automatically enabled in zswap+swapfc mode. Use zswap_enabled=0 to disable.
22+
# Requires a backing swap device (swap file or partition).
2323
################################################################################
2424

2525
zswap_compressor=zstd # lzo lz4 zstd lzo-rle lz4hc
26-
zswap_max_pool_percent=35 # Max % of RAM for compressed pool
26+
zswap_max_pool_percent=45 # Max % of RAM for compressed pool
2727
zswap_zpool=zsmalloc # Memory allocator
2828

2929
################################################################################
@@ -56,10 +56,13 @@ swapfc_path=/swapfc/swapfile # Path for swap files (must be btrfs)
5656
swapfc_frequency=1 # Check interval in seconds
5757

5858
################################################################################
59-
# Manual mode settings (only when swap_mode=manual)
59+
# Enable/disable settings
60+
# zswap_enabled: Set to 0 to disable zswap (default: 1, enabled when not using zram)
61+
# zram_enabled: Only used in manual mode
62+
# swapfc_enabled: Only used in manual mode
6063
################################################################################
6164

62-
zswap_enabled=0
65+
zswap_enabled=1
6366
zram_enabled=0
6467
swapfc_enabled=0
6568
swapd_auto_swapon=0

src/zswap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ pub fn start(config: &Config) -> Result<ZswapBackup> {
9696
info!("Zswap: backup current configuration: complete");
9797

9898
// Get config values
99-
let enabled = config.get("zswap_enabled").unwrap_or("0");
99+
// Default to "1" because if start() is called, zswap should be enabled
100+
let enabled = config.get("zswap_enabled").unwrap_or("1");
100101
let compressor = config.get("zswap_compressor").unwrap_or("lzo");
101102
let max_pool_percent = config.get("zswap_max_pool_percent").unwrap_or("20");
102103
let zpool = config.get("zswap_zpool").unwrap_or("zbud");

0 commit comments

Comments
 (0)