I need to turn off CPU cores in order to make energy measurements of sets of cpu cores in isolation (meaning that I want to run an application on a set of cpu cores and turn off the cpu cores that are not in the set). I looked at the documentation on the android linux kernel source and it says the following:
Q: How do i logically offline a CPU?
A: Do the following.
#echo 0 > /sys/devices/system/cpu/cpuX/online
Once the logical offline is successful, check
#cat /proc/interrupts
You should now not see the CPU that you removed. Also online file will report the state as 0 when a cpu if offline and 1 when its online.
#To display the current cpu state.
#cat /sys/devices/system/cpu/cpuX/online
But when I write 0 to the online file, it still reports the CPU as being online even with superuser permissions and marking the file as writable (chmod +w
).
I imagine that the kernel is enabling the cpu again after I disabled it. Also I did not try to turn off CPU 0 because in the same documentation it says that it's not removable in some architectures, this behavior is happening on other CPUs.
Do I need to rebuild the kernel in order to enable the cpu hotplug or is this an architecture specific problem? Maybe my cpu doesn't support hotplugs.
What I've tried by now
- Writing to
/sys/devices/system/cpu/cpuN/online
with a rooted device. (echo "0" > ./sys/device/...../online
) - Changing the kernel to a custom one and trying the step above again. (Kernel installed was Quantum Kernel)
- Using kernel adiutor to turn off the CPUs on the CPU tab (this turns off the CPU for a while then it turns back on again)
- Using su on adb shell to change file permissions on sysfs (
chmod 664 /sys/devices/...../online
) and then trying to write to it.
Device Information
Model: Samsung Galaxy A8 (SM-A530F)
Android Version: Android Pie (9)
Kernel: Quantum Kernel V4
Kernel version: 4.4.111-Quantum_pie.V4.0-A530F
Processor: Samsung Exynos Octa 7885
Architecture: aarch64
EDIT: Forgot to mention that my device is rooted.