From fc53a72f48ae6b567e7bf9901a2bd3657853633c Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 1 Apr 2015 18:54:52 +0200 Subject: 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 --- modules/module-list.nix | 1 + modules/system/ksm.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 modules/system/ksm.nix (limited to 'modules') 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 + ''; + }; + }; +} -- cgit 1.4.1