about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2019-07-06 08:54:34 +0100
committerGitHub <noreply@github.com>2019-07-06 08:54:34 +0100
commit2143f6f34fb715e8d987624fd1d5b087edb1e487 (patch)
treeac2388fe232f77bfc0eaf57ca62e1fd63916e4b0
parente111f2323358e0aec9274b3f7a4fb3ded620d962 (diff)
parent8364ade833e118d6649b30f935f7fc48ca509f76 (diff)
downloadnixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar.gz
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar.bz2
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar.lz
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar.xz
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.tar.zst
nixlib-2143f6f34fb715e8d987624fd1d5b087edb1e487.zip
Merge pull request #64355 from Izorkin/hardwareKSM
nixos/ksm: add option sleep
-rw-r--r--nixos/modules/hardware/ksm.nix22
-rw-r--r--nixos/modules/rename.nix3
2 files changed, 22 insertions, 3 deletions
diff --git a/nixos/modules/hardware/ksm.nix b/nixos/modules/hardware/ksm.nix
index d6ac69b5d65e..99d46c25236e 100644
--- a/nixos/modules/hardware/ksm.nix
+++ b/nixos/modules/hardware/ksm.nix
@@ -1,9 +1,24 @@
 { config, lib, ... }:
 
-{
-  options.hardware.enableKSM = lib.mkEnableOption "Kernel Same-Page Merging";
+with lib;
 
-  config = lib.mkIf config.hardware.enableKSM {
+let
+  cfg = config.hardware.ksm;
+
+in {
+  options.hardware.ksm = {
+    enable = mkEnableOption "Kernel Same-Page Merging";
+    sleep = mkOption {
+      type = types.nullOr types.int;
+      default = null;
+      description = ''
+        How many milliseconds ksmd should sleep between scans.
+        Setting it to <literal>null</literal> uses the kernel's default time.
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
     systemd.services.enable-ksm = {
       description = "Enable Kernel Same-Page Merging";
       wantedBy = [ "multi-user.target" ];
@@ -11,6 +26,7 @@
       script = ''
         if [ -e /sys/kernel/mm/ksm ]; then
           echo 1 > /sys/kernel/mm/ksm/run
+          ${optionalString (cfg.sleep != null) ''echo ${toString cfg.sleep} > /sys/kernel/mm/ksm/sleep_millisecs''}
         fi
       '';
     };
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index 7fa76dc0c688..1b77a895d717 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -241,6 +241,9 @@ with lib;
     # binfmt
     (mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
 
+    # KSM
+    (mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
+
   ] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
                    "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
                    "snmpExporter" "unifiExporter" "varnishExporter" ]