I have changed my system to using cpupools.
My log-in script that sets up the pools, my qubes autostart start script starts 10 qubes which is why I don’t remove all the p cores at the start, also why I have the 20 sec delay before I take the CPU out of performance mode.
#!/usr/bin/sh
/usr/sbin/xl cpupool-cpu-remove Pool-0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
/usr/sbin/xl cpupool-create name=\"pcores\" sched=\"credit2\"
/usr/sbin/xl cpupool-cpu-add pcores 8,9,10,11,12,13,14,15
/usr/sbin/xl cpupool-create name=\"ecores\" sched=\"credit2\"
/usr/sbin/xl cpupool-cpu-add ecores 16,17,18,19,20,21,22,23
/usr/sbin/xl cpupool-migrate sys-net ecores
/usr/sbin/xl cpupool-migrate sys-net-dm ecores
/usr/sbin/xl cpupool-migrate sys-usb ecores
/usr/sbin/xl cpupool-migrate sys-usb-dm ecores
/usr/sbin/xl cpupool-migrate sys-firewall ecores
/usr/sbin/xl cpupool-migrate sys-vpn ecores
/home/user/.scripts/qubes-autostart.sh
sleep 20
/usr/sbin/xl cpupool-cpu-remove Pool-0 4,5,6,7
/usr/sbin/xl cpupool-cpu-add pcores 4,5,6,7
/usr/sbin/xenpm set-scaling-governor ondemand
/usr/sbin/xenpm set-scaling-governor 0 performance
/usr/sbin/xenpm set-scaling-governor 1 performance
/usr/sbin/xenpm set-scaling-governor 2 performance
/usr/sbin/xenpm set-scaling-governor 3 performance
exit 0
The Python script changed from pinning to migrate
#!/usr/bin/python3.8
import asyncio
import subprocess
import qubesadmin
import qubesadmin.events
pools = []
pools.append(dict(name="sys-", cpupool="ecores"))
pools.append(dict(name="debian-", cpupool="ecores"))
pools.append(dict(name="kicksecure-", cpupool="ecores"))
pools.append(dict(name="disp-mgmt", cpupool="ecores"))
pools.append(dict(name="user", cpupool="pcores"))
pools.append(dict(name="default", cpupool="pcores"))
def _vcpu_pin(name, pool):
cmd = ['xl', 'cpupool-migrate', name, pool]
subprocess.run(cmd).check_returncode()
def pin_by_tag(vm, event, **kwargs):
vm = app.domains[str(vm)]
for pool in pools:
if vm.name.startswith(pool['name']):
break
elif pool['name'] == "default":
break
_vcpu_pin(vm.name, pool['cpupool'])
print(f"Pinned {vm.name} to cores ({pool['cpupool']})")
if str(getattr(vm, 'virt_mode')) == 'hvm':
_vcpu_pin(vm.name+'-dm', pool['cpupool'])
print(f"Pinned {vm.name}-dm to user-cores ({pool['cpupool']})")
app = qubesadmin.Qubes()
dispatcher = qubesadmin.events.EventsDispatcher(app)
dispatcher.add_handler('domain-start', pin_by_tag)
asyncio.run(dispatcher.listen_for_events())