From 753d37c21993283ac93352adb0c01a0cddce186d Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 14 Jul 2018 04:18:18 +0200 Subject: profiles/workstation: Refine zswap configuration Since kernel 4.18 contains the zstd compression module in the crypto API, it really makes sense to use that instead of the default (lzo) as it seems to have lower CPU usage with higher compression ratios. Another change I've made is to use z3fold for the pooling, so that 3 pages are cramped into one page of the pool. I did also have a look at zsmalloc, but it seems to come with the cost of additional CPU usage. Signed-off-by: aszlig --- .../user/aszlig/profiles/workstation/default.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/aszlig/profiles/workstation/default.nix b/modules/user/aszlig/profiles/workstation/default.nix index f0eb4501..c425d750 100644 --- a/modules/user/aszlig/profiles/workstation/default.nix +++ b/modules/user/aszlig/profiles/workstation/default.nix @@ -4,6 +4,9 @@ let cfg = config.vuizvui.user.aszlig.profiles.workstation; inherit (config.services.xserver) xrandrHeads; + kernelVersion = config.boot.kernelPackages.kernel.version; + hasZstd = lib.versionAtLeast kernelVersion "4.18"; + in { options.vuizvui.user.aszlig.profiles.workstation = { enable = lib.mkEnableOption "Workstation profile for aszlig"; @@ -12,7 +15,23 @@ in { config = lib.mkIf cfg.enable { vuizvui.user.aszlig.profiles.base.enable = true; - boot.kernelParams = [ "zswap.enabled=1" "panic=1800" ]; + boot.kernelPatches = lib.singleton { + name = "zswap-config"; + patch = null; + extraConfig = '' + CRYPTO_${if hasZstd then "ZSTD" else "LZO"} y + ZSWAP y + Z3FOLD y + ''; + }; + + boot.kernelParams = [ + "zswap.enabled=1" + "zswap.zpool=z3fold" + "zswap.compressor=${if hasZstd then "zstd" else "lzo"}" + "panic=1800" + ]; + boot.cleanTmpDir = true; environment.systemPackages = with lib; let -- cgit 1.4.1