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