From 5b97e3daf1f7e5c0ef8f4b630cb5b04b78587cac Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 20 Oct 2024 15:19:21 -0400 Subject: [PATCH] hwModules/legion/go: add udev rules and kernelParams from bazzite (#137) * hwModules/legion/go: disable monitoring in kernelParams * hwModules/legion/go: add bazzite storage udev rules * hwModules/legion/go: add bazzite udev rules * hwModules/legion/go: add bazzite sysctl settings * hwModules/legion/go: mkForce conflicting sysctl definitions * hwModules/legion/go: document --- hwModules/lenovo/legion/go/default.nix | 51 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/hwModules/lenovo/legion/go/default.nix b/hwModules/lenovo/legion/go/default.nix index 1605406c..f8fe9226 100644 --- a/hwModules/lenovo/legion/go/default.nix +++ b/hwModules/lenovo/legion/go/default.nix @@ -38,9 +38,38 @@ in { kernelModules = ["amdgpu"]; }; - blacklistedKernelModules = ["k10temp"]; + blacklistedKernelModules = ["k10temp"]; # Conflicts with zenpower extraModulePackages = with config.boot.kernelPackages; [acpi_call zenpower]; - kernelModules = ["zenpower"]; + + kernel.sysctl = { + # Improved file monitoring + "fs.inotify.max_user_instances" = 8192; + "fs.inotify.max_user_watches" = 524288; + + # Disable wtachdogs for maximum performance at the cost of resiliency + "kernel.nmi_watchdog" = 0; + "kernel.soft_watchdog" = 0; + "kernel.split_lock_mitigate" = 0; + "kernel.watchdog" = 0; + + # Network optimizations + "net.core.default_qdisc" = "fq"; + "net.ipv4.tcp_congestion_control" = "bbr"; + "net.ipv4.tcp_mtu_probing" = lib.mkForce 1; + + # Memory management + "vm.dirty_background_bytes" = 134217728; + "vm.dirty_bytes" = 268435456; + "vm.max_map_count" = lib.mkForce 2147483642; + "vm.page-cluster" = 0; + "vm.swappiness" = 180; + "vm.watermark_boost_factor" = 0; + "vm.watermark_scale_factor" = 125; + }; + + kernelModules = ["zenpower"]; # Improved temperature monitoring + + # Xanmod seems more responsive under load kernelPackages = lib.mkDefault pkgs.linuxPackages_xanmod_latest; }; @@ -108,6 +137,24 @@ in { '') ]; + udev.extraRules = '' + # Lenovo Legion Go Controller + ACTION=="add", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="6182", RUN+="${pkgs.kmod}/bin/modprobe xpad" RUN+="/bin/sh -c 'echo 17ef 6182 > /sys/bus/usb/drivers/xpad/new_id'" + + # Significantly improved I/O performance + ## SSD + ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber" + + ## NVME + ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber" + + ## MicroSD + ACTION=="add|change", KERNEL=="mmcblk[0-9]p[0-9]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" + + ## HDD + ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq" + ''; + upower.enable = true; }; }