From 8f850c7c6208776c0f6613cdd438cf92ffebb2ec Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 21 Nov 2024 01:06:03 +0200 Subject: [PATCH] Define hugepages mount in module --- flake.nix | 19 +++++++++++++++++++ pkgs/system-tools/default.nix | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index cd3840d..233f327 100644 --- a/flake.nix +++ b/flake.nix @@ -101,6 +101,25 @@ systemd = { # https://github.com/NixOS/nixpkgs/issues/81138 services.tenstorrent-hugepages.wantedBy = [ "sysinit.target" ]; + # Define https://github.com/tenstorrent/tt-system-tools/blob/29ba4dc6049eef3cee4314c53720417823ffc667/dev-hugepages%5Cx2d1G.mount + # because it has bad start ordering relations with tenstorrent-hugepages.service + # or it may be that the `wantedBy` does not work correctly in mounts like it does't work in serices. + mounts = [ + { + description = "Mount hugepages at /dev/hugepages-1G for Tenstorrent ASICs"; + what = "hugetlbfs"; + where = "/dev/hugepages-1G"; + type = "hugetlbfs"; + options = "pagesize=1G,mode=0777,nosuid,nodev"; + wantedBy = [ "sysinit.target" ]; + after = [ "tenstorrent-hugepages.service" ]; + unitConfig = { + DefaultDependencies = false; + ConditionPathExists = "/sys/kernel/mm/hugepages/hugepages-1048576kB"; + ConditionCapability = "CAP_SYS_ADMIN"; + }; + } + ]; packages = [ (pkgs.tt-system-tools or self.packages.${pkgs.hostPlatform.system}.system-tools) ]; diff --git a/pkgs/system-tools/default.nix b/pkgs/system-tools/default.nix index 0d99aac..53ef49b 100644 --- a/pkgs/system-tools/default.nix +++ b/pkgs/system-tools/default.nix @@ -33,7 +33,8 @@ stdenv.mkDerivation rec { runHook preInstall install -Dm444 -t $out/lib/systemd/system/ "tenstorrent-hugepages.service" - install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount' + # Defined in the module + #install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount' install -Dm555 -t $out/libexec/ "hugepages-setup.sh" runHook postInstall