NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.99k stars 14k forks source link

setting `dev.i915.perf_stream_paranoid` via `boot.kernel.sysctl` doesn't persist reboots #139182

Open CobaltCause opened 3 years ago

CobaltCause commented 3 years ago

Describe the bug

It appears that boot.kernel.sysctl don't automatically apply its configuration to the system correctly.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Stick the following into configuration.nix:
    boot.kernel.sysctl = {
    "dev.i915.perf_stream_paranoid" = false;
    };
  2. Run nixos-rebuild switch
  3. Optionally reboot, optionally repeat step 2
  4. sysctl dev.i915.perf_stream_paranoid will still report 1

Expected behavior

sysctl dev.i915.perf_stream_paranoid should report 0

Additional context

Manually running systemctl restart systemd-sysctl after step 2 or 3 will make step 4 report the expected value.

Notify maintainers

@Mic92 @flokli

Metadata

┌─[~]
└─[charles@worky]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.64, NixOS, 21.05.3208.8dd8bd8be74 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.15`
 - channels(root): `"nixos-21.05.3208.8dd8bd8be74"`
 - channels(charles): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
  - "boot.kernel.sysctl"
Artturin commented 3 years ago

the systemd-sysctl already has a restartTrigger for /etc/sysctl.d/60-nixos.conf

    systemd.services.systemd-sysctl =
      { wantedBy = [ "multi-user.target" ];
        restartTriggers = [ config.environment.etc."sysctl.d/60-nixos.conf".source ];
      };

for me the service gets restarted (monitored with journalctl -xe -f --unit=systemd-sysctl) when i change the value of "vm.swappiness" = 101;

CobaltCause commented 3 years ago

Hmm okay, trying this shows that it does actually work on my machine, but only after manually nixos-rebuild switching; it still won't apply automatically at boot. Your monitoring command shed some light on the source of the problem, it emitted

systemd-sysctl[736]: Couldn't write '0' to 'dev/i915/perf_stream_paranoid', ignoring: No such file or directory

while booting. But, I'm still not sure exactly how to resolve that

Artturin commented 3 years ago

what files are in /proc/sys/dev/i915/

CobaltCause commented 3 years ago
┌─[~]
└─[charles@worky]$ exa -T /proc/sys/dev/i915
/proc/sys/dev/i915
├── oa_max_sample_rate
└── perf_stream_paranoid
Artturin commented 3 years ago

does doing sudo sysctl -w dev.i915.perf_stream_paranoid=0 manually work

Artturin commented 3 years ago

repeat 10000 { cat /proc/sys/dev/i915/ } run this in zsh and rebuild and then check the output to check if the file disappears at some point

sadly inotifywait does not work on /proc files therefore we cant use this command $(nix-build '<nixos>' -A inotify-tools)/bin/inotifywait -m /proc/sys/vm/swappiness

Artturin commented 3 years ago

looks like this is a issue on other distros too https://forum.manjaro.org/t/cant-change-dev-i915-perf-stream-paranoid-to-0/66339

the command run by the systemd service can be run manually by doing $(nix-build '<nixos>' -A systemd)/lib/systemd/systemd-sysctl

Artturin commented 3 years ago

if this is an upstream issue and can't be fixed on our side then at least this should work

networking.localCommands = ''
  ${pkgs.procps}/bin/sysctl -w dev.i915.perf_stream_paranoid=0
'';
CobaltCause commented 3 years ago

does doing sudo sysctl -w dev.i915.perf_stream_paranoid=0 manually work

Yeah, it does

repeat 10000 { cat /proc/sys/dev/i915/ } run this in zsh and rebuild and then check the output to check if the file disappears at some point

sadly inotifywait does not work on /proc files therefore we cant use this command $(nix-build '<nixos>' -A inotify-tools)/bin/inotifywait -m /proc/sys/vm/swappiness

I tried the repeat command a few times but didn't see any errors

looks like this is a issue on other distros too https://forum.manjaro.org/t/cant-change-dev-i915-perf-stream-paranoid-to-0/66339

the command run by the systemd service can be run manually by doing $(nix-build '<nixos>' -A systemd)/lib/systemd/systemd-sysctl

Oh that's unfortunate. That command does work, though I have to run it as root. It appears to run without root but won't actually affect anything.

if this is an upstream issue and can't be fixed on our side then at least this should work

networking.localCommands = ''
  ${pkgs.procps}/bin/sysctl -w dev.i915.perf_stream_paranoid=0
'';

This does indeed work. Thank you!

Artturin commented 3 years ago

i only know that that sysctl option has this issue so the title should include it

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

PedroHLC commented 2 years ago

@stale This is still relevant.