about summary refs log tree commit diff
path: root/modules/system
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-04-01 18:54:52 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-04-01 18:54:52 +0200
commitfc53a72f48ae6b567e7bf9901a2bd3657853633c (patch)
treefcab156a8d35e8dfd7400ccbb56e833c503a0703 /modules/system
parent99f59ffb8c2fc5069c636cdbf589cf27f5a85ec6 (diff)
modules: Add a new system module to enable KSM.
This is very useful if you're running a lot of the same instances of
particular applications. For example virtual machines or even lots of
terminals.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/ksm.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/system/ksm.nix b/modules/system/ksm.nix
new file mode 100644
index 00000000..b54cedc9
--- /dev/null
+++ b/modules/system/ksm.nix
@@ -0,0 +1,20 @@
+{ config, lib, ... }:
+
+with lib;
+
+{
+  options.vuizvui.system.enableKSM = mkEnableOption "Kernel Same-Page Merging";
+
+  config = mkIf config.vuizvui.system.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
+      '';
+    };
+  };
+}