diff --git a/Makefile b/Makefile index c643d46..1567ac8 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,13 @@ all: hp0 hp3 hp0: scp -C ./hp0/* hp0: scp -C ./modules/* hp0: + scp -C ./scripts/* hp0: scp -C ./nix_switch.bash hp0: hp3: scp -C ./hp3/* hp3: scp -C ./modules/* hp3: + scp -C ./scripts/* hp3: scp -C ./nix_switch.bash hp3: # diff --git a/hp0/configuration.nix b/hp0/configuration.nix index e25f509..1f774f7 100644 --- a/hp0/configuration.nix +++ b/hp0/configuration.nix @@ -27,6 +27,7 @@ ./hosts.nix ./firewall.nix ./il8n.nix + ./systemdSystem.nix ./systemPackages.nix ./home-manager.nix ]; diff --git a/hp3/configuration.nix b/hp3/configuration.nix index 133d046..ad671d2 100644 --- a/hp3/configuration.nix +++ b/hp3/configuration.nix @@ -27,6 +27,7 @@ ./hosts.nix ./firewall.nix ./il8n.nix + ./systemdSystem.nix ./systemPackages.nix ./home-manager.nix ]; diff --git a/modules/systemdSystem.nix b/modules/systemdSystem.nix new file mode 100644 index 0000000..92f23c1 --- /dev/null +++ b/modules/systemdSystem.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ + # https://github.com/NixOS/nixpkgs/blob/095f1acb70302bd74cd5f3ab02a64bdfac36daa8/nixos/modules/system/boot/systemd.nix#L534 + # https://discourse.nixos.org/t/overriding-modifying-systemd-unit-file/45621/7 + + # https://mynixos.com/nixpkgs/options/systemd + systemd.extraConfig = "CPUAffinity=2-7"; + + #https://mynixos.com/options/systemd.user + systemd.user.extraConfig = "CPUAffinity=2-7"; + # create your own service + # https://discourse.nixos.org/t/how-to-use-toplevel-overrides-for-systemd/12501 +} \ No newline at end of file diff --git a/nix_switch.bash b/nix_switch.bash index 76ebabb..87c50b6 100644 --- a/nix_switch.bash +++ b/nix_switch.bash @@ -2,3 +2,6 @@ # sudo cp ./*.nix /etc/nixos/ sudo nixos-rebuild switch + + +#sudo ln -s /run/current-system/sw/bin/bash /usr/bin/bash \ No newline at end of file diff --git a/scripts/pin_nic_irqs.bash b/scripts/pin_nic_irqs.bash new file mode 100755 index 0000000..4ca245b --- /dev/null +++ b/scripts/pin_nic_irqs.bash @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# +# This script pins iwlwifi and enp1 to cores 0-1 +# +# https://www.kernel.org/doc/Documentation/IRQ-affinity.txt +# https://linux-kernel-labs.github.io/refs/heads/master/lectures/interrupts.html#interrupt-handling-in-linux +# in future consider +# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/network-rps + +# [das@hp0:~]$ cat /proc/interrupts | grep wifi +# 86: 0 0 0 4361163 0 0 0 0 IR-PCI-MSIX-0000:03:00.0 0-edge iwlwifi:default_queue +# 87: 527141 0 0 0 0 0 0 0 IR-PCI-MSIX-0000:03:00.0 1-edge iwlwifi:queue_1 +# 88: 0 36601 0 0 0 0 0 0 IR-PCI-MSIX-0000:03:00.0 2-edge iwlwifi:queue_2 +# 89: 0 0 549109 0 0 0 0 0 IR-PCI-MSIX-0000:03:00.0 3-edge iwlwifi:queue_3 +# 90: 0 0 0 393223 0 0 0 0 IR-PCI-MSIX-0000:03:00.0 4-edge iwlwifi:queue_4 +# 91: 0 0 0 0 1776763 0 0 0 IR-PCI-MSIX-0000:03:00.0 5-edge iwlwifi:queue_5 +# 92: 0 0 0 0 0 159677 0 0 IR-PCI-MSIX-0000:03:00.0 6-edge iwlwifi:queue_6 +# 93: 0 0 0 0 0 0 295033 0 IR-PCI-MSIX-0000:03:00.0 7-edge iwlwifi:queue_7 +# 94: 0 0 0 0 0 0 0 642178 IR-PCI-MSIX-0000:03:00.0 8-edge iwlwifi:queue_8 +# 95: 0 0 0 0 3 0 0 0 IR-PCI-MSIX-0000:03:00.0 9-edge iwlwifi:exception +# grep iwlwifi /proc/interrupts | awk '{ print $1 }' | sed -e 's/://' + +echo "starting to pin" +echo "BEFORE" +echo "grep iwlwifi /proc/interrupts" +grep iwlwifi /proc/interrupts + +for i in {86..95} +do + echo "Loop:${i}" + echo "echo 0-1 > /proc/irq/${i}/smp_affinity_list" + echo 0-1 > /proc/irq/"${i}"/smp_affinity_list + echo "cat /proc/irq/${i}/smp_affinity_list" + cat /proc/irq/"${i}"/smp_affinity_list +done + +echo "AFTER" +echo "grep iwlwifi /proc/interrupts" +grep iwlwifi /proc/interrupts + +#[das@hp0:~]$ grep eno /proc/interrupts +# 83: 0 0 0 0 0 0 0 0 IR-PCI-MSIX-0000:05:00.0 0-edge eno1 + +echo "echo 0-1 > /proc/irq/83/smp_affinity_list" +echo 0-1 > /proc/irq/83/smp_affinity_list