nixos/ksm: add option sleep
This commit is contained in:
parent
df738814d1
commit
8364ade833
|
@ -1,9 +1,24 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
with lib;
|
||||||
options.hardware.enableKSM = lib.mkEnableOption "Kernel Same-Page Merging";
|
|
||||||
|
|
||||||
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 = {
|
systemd.services.enable-ksm = {
|
||||||
description = "Enable Kernel Same-Page Merging";
|
description = "Enable Kernel Same-Page Merging";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
@ -11,6 +26,7 @@
|
||||||
script = ''
|
script = ''
|
||||||
if [ -e /sys/kernel/mm/ksm ]; then
|
if [ -e /sys/kernel/mm/ksm ]; then
|
||||||
echo 1 > /sys/kernel/mm/ksm/run
|
echo 1 > /sys/kernel/mm/ksm/run
|
||||||
|
${optionalString (cfg.sleep != null) ''echo ${toString cfg.sleep} > /sys/kernel/mm/ksm/sleep_millisecs''}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -241,6 +241,9 @@ with lib;
|
||||||
# binfmt
|
# binfmt
|
||||||
(mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
|
(mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
|
||||||
|
|
||||||
|
# KSM
|
||||||
|
(mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
|
||||||
|
|
||||||
] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
|
] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
|
||||||
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
|
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
|
||||||
"snmpExporter" "unifiExporter" "varnishExporter" ]
|
"snmpExporter" "unifiExporter" "varnishExporter" ]
|
||||||
|
|
Loading…
Reference in New Issue