Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: Switch to schedutil governor #42330

Closed
wants to merge 1 commit into from

Conversation

NeQuissimus
Copy link
Member

@NeQuissimus NeQuissimus commented Jun 21, 2018

Motivation for this change

Since 4.9, the Linux kernel has included the "schedutil" CPU governor (in its current implementation): https://cateee.net/lkddb/web-lkddb/CPU_FREQ_GOV_SCHEDUTIL.html

This governor adjusts the CPU frequency based on utilization data provided by the scheduler.

Switching to this governor should allow for energy-savings while still making "high-performance" possible.

Closes #41003

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Add these to my config:

boot.kernelParams = [ "intel_pstate=passive" ];
powerManagement.cpuFreqGovernor = "schedutil";
λ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
schedutil
λ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
performance schedutil
λ systemctl status cpufreq.service
● cpufreq.service - CPU Frequency Governor Setup
   Loaded: loaded (/nix/store/lzk05z7a3l0gslpsbrmh8qcacmvzw65x-unit-cpufreq.service/cpufreq.service; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2018-06-21 10:30:01 EDT; 35min ago
  Process: 838 ExecStart=/nix/store/c1zaswjv476fyxdkl78yr6816wnp9qrb-cpupower-4.16.16/bin/cpupower frequency-set -g schedutil (code=exited, status=0/SUCCESS)
 Main PID: 838 (code=exited, status=0/SUCCESS)

Jun 21 10:30:01 nixus-desktop systemd[1]: Starting CPU Frequency Governor Setup...
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 0
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 1
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 2
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 3
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 4
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 5
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 6
Jun 21 10:30:01 nixus-desktop cpupower[838]: Setting cpu: 7
Jun 21 10:30:01 nixus-desktop systemd[1]: Started CPU Frequency Governor Setup.

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: linux

Partial log (click to expand)

while evaluating the attribute 'linux_4_14' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/top-level/all-packages.nix:13599:3:
while evaluating 'callPackageWith' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:113:35, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/top-level/all-packages.nix:13599:16:
while evaluating 'makeOverridable' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:72:24, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:117:8:
while evaluating anonymous function at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/os-specific/linux/kernel/linux-4.14.nix:1:1, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:74:12:
while evaluating 'buildLinux' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/top-level/all-packages.nix:13914:16, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/os-specific/linux/kernel/linux-4.14.nix:5:1:
while evaluating 'callPackageWith' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:113:35, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/top-level/all-packages.nix:13914:23:
while evaluating 'makeOverridable' at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:72:24, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:117:8:
while evaluating anonymous function at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/os-specific/linux/kernel/generic.nix:1:1, called from /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/lib/customisation.nix:74:12:
assertion failed at /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/os-specific/linux/kernel/generic.nix:48:1

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: linux

Partial log (click to expand)

wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
wrong ELF type
cannot find section .dynamic
/nix/store/x1v2mnr78smxfiw3dhkm4nccr0z5r8fh-linux-4.14.51

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: linux

Partial log (click to expand)

  CC [M]  drivers/usb/host/isp1362-hcd.o
  CC [M]  drivers/staging/lustre/lustre/llite/vvp_dev.o
  CC [M]  drivers/staging/lustre/lustre/lmv/lmv_intent.o
  CC [M]  drivers/scsi/esp_scsi.o
  CC [M]  drivers/usb/host/ohci-hcd.o
  CC [M]  drivers/staging/lustre/lustre/llite/vvp_page.o
  CC [M]  drivers/staging/lustre/lustre/lmv/lmv_fld.o
  CC [M]  drivers/scsi/am53c974.o
building of '/nix/store/vsiillchn2k6di0nnrwaazp226pg2pw9-linux-4.14.51.drv' timed out after 1800 seconds
error: build of '/nix/store/vsiillchn2k6di0nnrwaazp226pg2pw9-linux-4.14.51.drv' failed

@edolstra
Copy link
Member

If this is a fairly new scheduler, is it a good idea to make it the default? What do the kernel developers recommend? What do other distributions do?

@NeQuissimus
Copy link
Member Author

I only checked with Arch and Ubuntu, and they both use schedutil as the default.

@NeQuissimus NeQuissimus added this to the 18.09 milestone Jun 22, 2018
@@ -75,6 +75,11 @@ with stdenv.lib;
''}
INTEL_IDLE y
CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
${optionalString (versionAtLeast version "4.9") ''
CPU_FREQ_GOV_SCHEDUTIL y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NeQuissimus
Since its been almost a month without feedback from other people here, I think it would be fine to just allow people to use schedutil but not change the default governor yet. Currently no one can use this.

Copy link
Contributor

@xaverdh xaverdh Jul 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with worldofpeace. This should probably be split into two pull requests, one allowing users to use schedutil in the first place, and another that suggests changing the defaults.
That will also allow people to test things out, and / or draw their attention to the fact, that this exists at all.

@orivej
Copy link
Contributor

orivej commented Jul 15, 2018

It's good to build schedutil (probably as a module, like other governors), but it is not an alternative to performance and should not replace it. The default built into the kernel does not matter on NixOS anyway because nixos-generate-config configures powerManagement.cpuFreqGovernor that overrides it, currently to ondemand or powersave; this list may be changed to prefer schedutil. Note that the unset powerManagement.cpuFreqGovernor is documented to mean performance.

@xaverdh
Copy link
Contributor

xaverdh commented Jul 15, 2018

It's good to build schedutil (probably as a module, like other governors), [...]

Note: As I understand it now, on recent kernel versions schedutil can no longer be built as a module.

@NeQuissimus
Copy link
Member Author

As mentioned above, schedutil cannot be built as a module.
Not sure how we should proceed with this. Any suggestions?
Set CPU_FREQ_GOV_SCHEDUTIL but not CPU_FREQ_DEFAULT_GOV_SCHEDUTIL (if that is valid)?

@xeji
Copy link
Contributor

xeji commented Aug 30, 2018

For now, let's enable schedutil but not make it the default, and review the default for 19.03 after people have used it for a while.

@vcunat
Copy link
Member

vcunat commented Aug 30, 2018

Right, e6a37e3. We can continue the discussion about the default, though that might be better after several months (I don't really know, I haven't researched pros and cons).

vcunat added a commit that referenced this pull request Aug 30, 2018
- it can't be built as a module
- it's not set as the default yet
- for discussion see #42330
@samueldr samueldr modified the milestones: 18.09, 19.03 Aug 30, 2018
@brainrake
Copy link
Contributor

brainrake commented Sep 1, 2018

Can we close this?

  • enabling schedutil is solved by e6a37e3
  • setting it as the default as it is done in this PR is not effective
  • setting it as the default should be a separate PR

Thanks!

@vcunat vcunat closed this Sep 1, 2018
@NeQuissimus NeQuissimus deleted the schedutil branch February 14, 2021 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet