Add AMD uProf module and enable it in fox

This commit is contained in:
Rodrigo Arias 2025-06-20 15:51:46 +02:00
parent 4eb2bf5fcf
commit e0ecd2be0c
2 changed files with 42 additions and 0 deletions

View File

@ -5,6 +5,7 @@
../common/base.nix
../common/xeon/console.nix
../module/emulation.nix
../module/amd-uprof.nix
];
# Select the this using the ID to avoid mismatches
@ -22,6 +23,8 @@
# Use performance for benchmarks
powerManagement.cpuFreqGovernor = "performance";
services.amd-uprof.enable = true;
networking = {
timeServers = [ "ntp1.upc.edu" "ntp2.upc.edu" ];
hostName = "fox";

39
m/module/amd-uprof.nix Normal file
View File

@ -0,0 +1,39 @@
{ config, lib, pkgs, ... }:
{
options = {
services.amd-uprof = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable AMD uProf.";
};
};
};
# Only setup amd-uprof if enabled
config = lib.mkIf config.services.amd-uprof.enable {
# First make sure that we add the module to the list of available modules
# in the kernel matching the same kernel version of this configuration.
boot.extraModulePackages = with config.boot.kernelPackages; [ amd-uprof-driver ];
# Make the userspace tools available in $PATH.
environment.systemPackages = with pkgs; [ amd-uprof ];
# Add extra udev rules to setup the /dev/AMDPowerProfiler device. They
# forgot to add these.
services.udev.extraRules = let
# To create the device node we need to read the device number from the
# /proc directory, so the module must have been loaded first.
addDevice = pkgs.writeScript "add-amd-uprof-dev.sh"
"mknod /dev/AMDPowerProfiler -m 666 c $(< /proc/AMDPowerProfiler/device) 0";
removeDevice = pkgs.writeScript "remove-amd-uprof-dev.sh"
"rm /dev/AMDPowerProfiler";
in
''
SUBSYSTEM=="module", DEVPATH=="/module/AMDPowerProfiler/device", ACTION=="add", RUN+="${addDevice}"
SUBSYSTEM=="module", DEVPATH=="/module/AMDPowerProfiler/device", ACTION=="remove", RUN+="${removeDevice}"
'';
};
}