From 224ed7e798caf80e65250385a9cb0ab09c52d2c7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 1 Apr 2015 19:55:49 +0200 Subject: [PATCH] nixos/hardware: Add option to enable KSM. This is essentially what's been done for the official NixOS build slaves and I'm using it as well for a few of my machines and my own Hydra slaves. Here's the same implementation from the Delft server configurations: https://github.com/NixOS/nixos-org-configurations/blob/f47c2fc7f82cc8aa4ea8047487cbb819d6829fe2/delft/common.nix#L91-L101 Signed-off-by: aszlig --- nixos/modules/hardware/ksm.nix | 18 ++++++++++++++++++ nixos/modules/module-list.nix | 1 + 2 files changed, 19 insertions(+) create mode 100644 nixos/modules/hardware/ksm.nix diff --git a/nixos/modules/hardware/ksm.nix b/nixos/modules/hardware/ksm.nix new file mode 100644 index 000000000000..d6ac69b5d65e --- /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 + ''; + }; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 738faa79e29b..33830dbc8102 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -29,6 +29,7 @@ ./hardware/all-firmware.nix ./hardware/cpu/amd-microcode.nix ./hardware/cpu/intel-microcode.nix + ./hardware/ksm.nix ./hardware/network/b43.nix ./hardware/network/intel-2100bg.nix ./hardware/network/intel-2200bg.nix