It is known the way to disable logical CPUs in Linux, basically with echo 0 > /sys/devices/system/cpu/cpu<number>/online
. This way, you are only telling to the OS to ignore that given (<number>
) CPU.
My question goes further, is it possible not only to ignore it but to turn it off physically programmatically? I want that CPU to not receive any power, in order to make its energy consumption zero.
I know that it is possible disable cores from the BIOS (not always), but I want to know whether is possible to do it within a certain program or not.
From the System Utilities screen, select System Configuration > BIOS/Platform Configuration (RBSU) > System Options > Processor Options > Processor Core Disable and press Enter.
Execute Linux command "echo 0 > /sys/devices/system/cpu/cpu3/online" to disable CPU core.
Limiting actual usage is done by using the –limit or -l switch option to set the CPU percentage for a process. Please note that total CPU percentage available is usually (100 x number of CPU Cores). Use top, or even better, install htop and use this to find the offending program.
above command loads kernel image there we are manually passing “isolcpus=2” parameter to isolate CPU number 2. after this change we can boot the kernel by pressing F10 or as mentioned in grub note. After this once system boots cpu2 will be isolated and no user/kernel process is loaded.
In Windows systems, it is possible to disable a core through the system configuration window. Choose the number of processors that should be enabled or disabled and restart the computer for the settings to take effect. Disabling a core in Linux can be done through the grub menu and add parameters to the kernel entry.
This effectively puts CPU to the power-saving state until it is woken up by another CPU at user request. If you have a laptop, you can verify that power draw indeed goes down when you disable the core by reading the power from /sys/class/power_supply/BAT {0,1}/current_now (or uevent for all values such as voltage) or using the "powertop" utility.
Depending on your need, there are actually 3 ways to accomplish it. The first method disables cores for the whole system. The second turns them off for a specific program. Finally, you may just want to shut off those fake Hyperthreading cores.
In the System Configuration window click on the Atart sub menu and the on Advanced Options button In the second window that appears, you should be provided with an option for enabling and disabling the processors as you wish What is the procedure when using Linux? When using Linux the procedure is quite different.
When you do echo 0 > /sys/devices/system/cpu/cpu<number>/online
, what happens next depends on the particular CPU. On ARM embedded systems the kernel will typically disable the clock that drives the particular core PLL so effectively you get what you want.
On Intel X86 systems, you can only disable the interrupts and call the hlt
instruction (which Linux Kernel does). This effectively puts CPU to the power-saving state until it is woken up by another CPU at user request. If you have a laptop, you can verify that power draw indeed goes down when you disable the core by reading the power from /sys/class/power_supply/BAT{0,1}/current_now
(or uevent
for all values such as voltage) or using the "powertop" utility.
For example, here's the call chain for disabling the CPU core in Linux Kernel for Intel CPUs. https://github.com/torvalds/linux/blob/master/drivers/cpufreq/intel_pstate.c
arch/x86/kernel/smp.c
: smp_ops.play_dead = native_play_dead,
arch/x86/kernel/smpboot.c
: native_play_dead()
-> play_dead_common()
-> local_irq_disable()
Before that, CPUFREQ also sets the CPU to the lowest power consumption level before disabling it though this does not seem to be strictly necessary.
intel_pstate_stop_cpu
-> intel_cpufreq_stop_cpu
-> intel_pstate_set_min_pstate
-> intel_pstate_set_pstate
-> wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, pstate_funcs.get_val(cpu, pstate));
On Intel X86 there does not seem to be an official way to disable the actual clocks and voltage regulators. Even if there was, it would be specific to the motherboard and thus your closest bet might be looking into BIOS such as coreboot. Hmm, I realized I have no idea about Intel except looking into kernel sources.
In Windows 10 it became possible with new power management commands CPMINCORES CPMAXCORES.
Powercfg -setacvalueindex scheme_current sub_processor CPMAXCORES 50
Powercfg -setacvalueindex scheme_current sub_processor CPMINCORES 25
Powercfg -setactive scheme_current
Here 50% of cores are assigned for desired deep sleep, and 25% are forbidden to be parked. Very good in numeric simulations requiring increased clock rate (15% boost on Intel)
You can not choose which cores to park, but Windows 10 kernel checks Intel's Comet Lake and newer "prefered" (more power efficient) cores, and starts parking those not preferred. It is not a strict parking, so at high load the kernel can use these cores with very low load.
just in case if you are looking for alternatives
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With