NGnius / PowerTools

Moved to
https://git.ngni.us/NG-SD-Plugins/PowerTools
GNU General Public License v3.0
414 stars 29 forks source link

"Best Core"-aware slider #24

Closed Samuel-B-D closed 1 year ago

Samuel-B-D commented 2 years ago

Looking back at this issue #12, I am not sure the anwser here is completely right; I am not sure if it apply to the Steam Deck's APU specifically, but since Zen 2, AMD's CPUs have a notion of "best core" (and second-best-core), which identify which core of that particular CPU's silicon perform better and usually boost higher than the other cores. In windows, the scheduler is aware of that and will try to assign game's main thread to this core for better performances. https://www.anandtech.com/show/15137/amd-clarifies-best-cores-vs-preferred-cores

I do not know at all if the scheduler in Linux kernel is aware of this, but if it is, then these should be the last cores to be disabled by the slider, as it should technically provide either performance or battery life advantages (albeit probably pretty small)

NGnius commented 2 years ago

This would be something interesting to investigate! The article seems to indicate that AMD doesn't have support for this in Linux, but that could've changed.

Some caveats to consider/research:

As it stands, I'm going to mark this as missing information since, through no fault of your own, more research is required.

Samuel-B-D commented 2 years ago

HWiNFO is able to list the order of "best-to-worse" cores as shown in the article. I'll try to do some more research and tinkering with my own deck :)

NGnius commented 2 years ago

Here's some disappointing research: According to the original article, this feature is exposed through CPPC2, which is part of UEFI (aka the modern BIOS). The Steam Deck uses UEFI, so that's fine.

Unfortunately, the Linux kernel docs says that /sys/devices/system/cpu/cpuX/acpi_cppc/ should exist (where X is a valid cpu number), but it doesn't on the Steam Deck.

Phoronix suggests that CPPC (not 2) support was added a while ago (for Linux kernel 5.3 or 5.4), but is disabled by default. The kernel boot parameter to enable it is not present on my Steam Deck.

BOOT_IMAGE=/boot/vmlinuz-linux-neptune console=tty1 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.systemd.gpt_auto=no module_blacklist=tpm amd_iommu=off amdgpu.gttsize=8128 spi_amd.speed_dev=1 audit=0 fbcon=rotate:1 loglevel=3 splash quiet plymouth.ignore-serial-consoles fbcon=vc:4-6 steamos.efi=PARTUUID=<snip>

I think this is the original patch to add CPPC (still not 2) for AMD Zen 2. I suspect Van Gogh is too special to have gotten support in that. EDIT: I was partly correct: amd_cpufreq was never merged so everything was too special to get support)

On the other hand, /sys/firmware/acpi and /sys/firmware/efi both exist on my Deck, and may have some hidden goodies that I've yet to find.

With some help from some people on the Decky Discord, we've found there's work on an AMD p-state driver (with help from Valve, for the Steam Deck!), but it's only in 5.17 and is disabled by default. Steam Deck is 5.13 so that's a no-go.

They also found this repo for setting voltage of lots of AMD CPUs using the msr kernel module, which I don't understand at all so that's worth some further research.

NGnius commented 1 year ago

Removing milestone and closing this issue since I don't think this is going to work anytime soon. I'm not against revisiting this if it does become possible later, though. The changes for #48 would make a change like this pretty easy to implement once the detection hurdle is overcome.