mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
nixos/ksm: add option sleep
This commit is contained in:
parent
df738814d1
commit
8364ade833
@ -1,9 +1,24 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
options.hardware.enableKSM = lib.mkEnableOption "Kernel Same-Page Merging";
|
||||
with lib;
|
||||
|
||||
config = lib.mkIf config.hardware.enableKSM {
|
||||
let
|
||||
cfg = config.hardware.ksm;
|
||||
|
||||
in {
|
||||
options.hardware.ksm = {
|
||||
enable = mkEnableOption "Kernel Same-Page Merging";
|
||||
sleep = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
default = null;
|
||||
description = ''
|
||||
How many milliseconds ksmd should sleep between scans.
|
||||
Setting it to <literal>null</literal> uses the kernel's default time.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.enable-ksm = {
|
||||
description = "Enable Kernel Same-Page Merging";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
@ -11,6 +26,7 @@
|
||||
script = ''
|
||||
if [ -e /sys/kernel/mm/ksm ]; then
|
||||
echo 1 > /sys/kernel/mm/ksm/run
|
||||
${optionalString (cfg.sleep != null) ''echo ${toString cfg.sleep} > /sys/kernel/mm/ksm/sleep_millisecs''}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
@ -241,6 +241,9 @@ with lib;
|
||||
# binfmt
|
||||
(mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
|
||||
|
||||
# KSM
|
||||
(mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
|
||||
|
||||
] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
|
||||
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
|
||||
"snmpExporter" "unifiExporter" "varnishExporter" ]
|
||||
|
Loading…
Reference in New Issue
Block a user