6 cfg = config.hardware.ksm;
10 (mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
13 options.hardware.ksm = {
14 enable = mkEnableOption (lib.mdDoc "Kernel Same-Page Merging");
16 type = types.nullOr types.int;
18 description = lib.mdDoc ''
19 How many milliseconds ksmd should sleep between scans.
20 Setting it to `null` uses the kernel's default time.
25 config = mkIf cfg.enable {
26 systemd.services.enable-ksm = {
27 description = "Enable Kernel Same-Page Merging";
28 wantedBy = [ "multi-user.target" ];
31 echo 1 > /sys/kernel/mm/ksm/run
32 '' + optionalString (cfg.sleep != null)
34 echo ${toString cfg.sleep} > /sys/kernel/mm/ksm/sleep_millisecs