about summary refs log tree commit diff
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
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>
-rw-r--r--modules/module-list.nix1
-rw-r--r--modules/system/ksm.nix20
2 files changed, 21 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix
index 2b7e31b6..bebc5ebc 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -2,6 +2,7 @@
   ./profiles/common.nix
   ./services/multipath-vpn.nix
   ./services/postfix
+  ./system/ksm.nix
   ./user/aszlig/profiles/base.nix
   ./user/aszlig/profiles/workstation
   ./user/aszlig/programs/gajim
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
+      '';
+    };
+  };
+}