I want to disable 3 CPU cores and run my processor on a single core. I have used command:maxcpus=1. But after this I executed this command ls /sys/devices/system/cpu. It still shows cpu0,cpu1,cpu2,cpu3.

I also tried :echo 0 > /sys/devices/system/cpu3/online but I get the following error: no such file or directory.

share|improve this question
    
It is unclear where you put the maxcpus=1 commmand? Did you put that string in grub.cfg as a boot option? (Please update your question instead of answering in comments). – Anthon Jul 21 '14 at 7:24
    
I am using freescale IMx6 sabreauto board on linux OS.I executed the command on a terminal emulator "gtkterm" – user3818847 Jul 21 '14 at 7:41
    
With this command echo 0 > /sys/devices/system/cpu3/online I am able to see cpu3 shutdown. Now what I want know is, should I reboot the system for the changes to effect or I can continue without rebooting – user3818847 Jul 21 '14 at 7:45
    
AFAIK you should specify maxcpus=1 as a parameter to the kernel (i.e. when you are in grub). Edit '/etc/defaults/grub' to add it to the kernel parameters, run 'update-grub' and reboot. That will make things persistent, i.e. with only one CPU on Linux startup. – Anthon Jul 21 '14 at 8:55
1  
@user3818847 what distro are you using? Modifying the boot parameters (to pass maxcpus=1) varies by distro. Also the /sys path you have is simply the wrong one, the correct path is /sys/devices/system/cpu/cpu3/online. – Patrick Jul 21 '14 at 13:00

As Patrick has indicated in a comment, you got the path under /sys wrong.

echo 0 > /sys/devices/system/cpu/cpu3/online

If you want to switch all CPUs off (except cpu0 which can't be switched off):

for x in /sys/devices/system/cpu/cpu*/online; do
  echo 0 >"$x"
done

Typing maxcpus=1 at a shell prompt has no effect. More precisely, it sets the variable maxcpus to the value 1 in that shell, which doesn't have any other effect. You can set the number of CPUs at boot time by passing maxcpus as a kernel parameter. For that, you have to change your bootloader configuration (e.g. to change the kernel command line in U-Boot).

share|improve this answer
    
Thank you for the suggestions. It worked with the command suggested by you – user3818847 Jul 22 '14 at 9:25
    
This is at least somewhat kernel-specific. I'm running kernel 3.6.6, and there's no such files; you instead use the single /sys/devices/system/cpu/online and ./offline files to control all the cores. – Daniel Griscom May 9 '17 at 21:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.