summary refs log tree commit diff
path: root/nixos/modules/hardware/ksm.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/hardware/ksm.nix')
-rw-r--r--nixos/modules/hardware/ksm.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/nixos/modules/hardware/ksm.nix b/nixos/modules/hardware/ksm.nix
new file mode 100644
index 00000000000..d6ac69b5d65
--- /dev/null
+++ b/nixos/modules/hardware/ksm.nix
@@ -0,0 +1,18 @@
+{ config, lib, ... }:
+
+{
+  options.hardware.enableKSM = lib.mkEnableOption "Kernel Same-Page Merging";
+
+  config = lib.mkIf config.hardware.enableKSM {
+    systemd.services.enable-ksm = {
+      description = "Enable Kernel Same-Page Merging";
+      wantedBy = [ "multi-user.target" ];
+      after = [ "systemd-udev-settle.service" ];
+      script = ''
+        if [ -e /sys/kernel/mm/ksm ]; then
+          echo 1 > /sys/kernel/mm/ksm/run
+        fi
+      '';
+    };
+  };
+}