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