From b8eb81e8735f0bcd72726426d354c59b40539bb9 Mon Sep 17 00:00:00 2001 From: "PAEPCKE, Michael" Date: Mon, 5 May 2025 22:52:02 +0000 Subject: [PATCH] nixos/boot/tmp: introduce adaptive huge memory pages --- nixos/modules/system/boot/tmp.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nixos/modules/system/boot/tmp.nix b/nixos/modules/system/boot/tmp.nix index 9ec02c594cf0..f927ba1c9c90 100644 --- a/nixos/modules/system/boot/tmp.nix +++ b/nixos/modules/system/boot/tmp.nix @@ -31,6 +31,23 @@ in ''; }; + tmpfsHugeMemoryPages = lib.mkOption { + type = lib.types.enum [ + "never" + "always" + "within_size" + "advise" + ]; + default = "never"; + example = "within_size"; + description = '' + never - Do not allocate huge memory pages. This is the default. + always - Attempt to allocate huge memory page every time a new page is needed. + within_size - Only allocate huge memory pages if it will be fully within i_size. Also respect madvise(2) hints. Recommended. + advise - Only allocate huge memory pages if requested with madvise(2). + ''; + }; + useTmpfs = lib.mkOption { type = lib.types.bool; default = false; @@ -60,6 +77,7 @@ in "nosuid" "nodev" "size=${toString cfg.tmpfsSize}" + "huge=${cfg.tmpfsHugeMemoryPages}" ]; } ];