Define hugepages mount in module

This commit is contained in:
Artturin 2024-11-21 01:06:03 +02:00
parent 66bf540c3e
commit 8f850c7c62
2 changed files with 21 additions and 1 deletions

View file

@ -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)
];

View file

@ -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