Qubes Cpu Pinning: automatically pin CPUs for VMs

@Talkabout Audio dropouts and stutter - #40 by Talkabout I presume you meant this script and not Window Boost.

It would be very easy to implement with psutil:

user@dom0 ~ % python3
Python 3.11.6 (main, Oct  3 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.sensors_battery().power_plugged
True

Personally, I’d still prefer to pin qubes to p-cores even on battery power, but I can see your use-case.

Implementing this in the vCPU pinning script would be very simple and I will gladly accept a PR (or do it myself, but I don’t think I’ll have time right now). It would not apply to aleady-started qubes, though, so that makes me think that it may be a good idea to also write something that would use udev triggers to re-pin all VMs to e-cores on battery power. Technically it could be integrated within this script, too (maybe via pyudev).

EDIT:

For what it’s worth, it may also be interesting to consider applying settings for xen_hwp, e.g. xenpm set-cpufreq-hwp powersave maximum:25 for power saving and xenpm set-cpufreq-hwp balance otherwise.