#Is it possible to disable some CPU cores at runtime? UPD: unbloat energy usage when on battery

1 messages · Page 1 of 1 (latest)

dusky topaz
#

Is it possible to disable some cores at runtime?

pure kite
#

Yes, you can use a program like taskset to specify threads.

As an example, for a 8 core/16 thread CPU, if I wanted both threads belonging to core 0, I would set:

taskset -c 0,8 emerge

now emerge will only use thread 0 and 8

pure kite
#

Depending on the setup, you could do something like:
taskset -c 0,8 startx, anything inside the X session will use the threads assigned

heavy marten
#

systemctl set-property --runtime user.slice AllowedCPUs=4-7

#

can also set system.slice and machine.slice

#

that's for systemd

vast flume
#

Strictly speaking yes, but remember that the silicon is supposed to be assigning things to the most power efficient core for the workload at a given time; you could tell the scheduler not to use certain cores or to prefer certain cores
echo 0 > /sys/devices/system/cpu/cpu1/online
But its not turning it "off" it's just not using that core.

Do some testing while you have power to see if it helps, and good luck!

#

Remember that you can use the binhost for most packages if you aren't deviating too far from the defaults

#

Also check for settings in your UEFI

heavy marten
#

I actually tried that echo command and it did not have the desired result. Processes were still being assigned to the core I had just turned off. Still haven't' figured out why. I could even cat the contents of the file and it was 0. Core remained in the available pool. Maybe it's a kernel config I'm missing.

#

Also, intel's thread scheduler doesn't do a great job at sending processes to P/E cores. I've seen plenty of tasks that needed P, end up on E. If the core isn't in use, it will obviously get throttled back, so there is still a power savings. Probably small.

pure kite
#

I haven't done it before, but maybe CPU limiting through cgroups could be viable for system wide stuff?

heavy marten
#

systemctl is using cgroups as deets calls out above. On my system I can echo 4-7 > /sys/fs/cgroup/system.slice/cpuset.cpus Or to the other .slices I mentioned previously. I don't know if the *.slices are a systemd-generated thing or not. Cgroups is how you'd have to do this if they are not there in openrc. Create a folder there as root mkdir /sys/fs/cgroup/blah and if your kernel is configured correctly, in that new folder you should see cpuset.cpus and cgroups.proc to set the cores and PIDs respectively with echo as above.

vast flume
#

You can't disable cpu0

dusky topaz
#

Is it possible to disable some cores at runtime? UPD: unbloat energy usage when on battery

heavy marten
#

taskset and cgroups are doing the same thing. Just different paths. You can put multiple PIDs into a cgroup folder: echo $pid >> cgroup.procs. Might also have to run echo +cpuset +pids > /sys/fs/cgroup/cgroup.subtree_control to enable all the control files if they're not in the new control folders.

Boot parameters are an option too: isolcpus=0-3 will remove those cores from the thread scheduler list though it sounded like you were looking for runtime tweaks. You might as well tweak the bios at that point.

vast flume
#

How recent is the NVIDIA card? You might be able to power it off entirely if its 2000 series or newer

vast flume
#

Might be able to save 1w!

dusky topaz
#

Is it possible to disable some cores at runtime? UPD: unbloat energy usage when on battery CPU