mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2026-07-21 20:41:25 +02:00
modules/hugepages: init
This commit is contained in:
@@ -309,6 +309,7 @@
|
|||||||
bluemap = ./modules/bluemap.nix;
|
bluemap = ./modules/bluemap.nix;
|
||||||
drumknotty = ./modules/drumknotty;
|
drumknotty = ./modules/drumknotty;
|
||||||
gickup = ./modules/gickup;
|
gickup = ./modules/gickup;
|
||||||
|
hugepages = ./modules/hugepages.nix;
|
||||||
matrix-ooye = ./modules/matrix-ooye.nix;
|
matrix-ooye = ./modules/matrix-ooye.nix;
|
||||||
python-http-handlers = ./modules/python-http-handlers.nix;
|
python-http-handlers = ./modules/python-http-handlers.nix;
|
||||||
robots-txt = ./modules/robots-txt.nix;
|
robots-txt = ./modules/robots-txt.nix;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.boot.kernel.hugepages;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.boot.kernel.hugepages = {
|
||||||
|
size = lib.mkOption {
|
||||||
|
type = lib.types.enum [ 2 1024 ];
|
||||||
|
default = 2;
|
||||||
|
description = ''
|
||||||
|
Hugepage size in MB.
|
||||||
|
|
||||||
|
You can use this value to calculate the amount of memory you will have available as hugepages.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
reservations = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.ints.unsigned;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Number of hugepages each service wants reserved in vm.nr_hugepages,
|
||||||
|
keyed by service name.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.kernelParams = let
|
||||||
|
num = {
|
||||||
|
"2" = "2M";
|
||||||
|
"1024" = "1G";
|
||||||
|
}.${toString cfg.size};
|
||||||
|
in [ "hugepagesz=${num}" ];
|
||||||
|
|
||||||
|
boot.kernel.sysctl."vm.nr_hugepages" =
|
||||||
|
lib.foldl' (a: b: a + b) 0 (lib.attrValues cfg.reservations);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user