Sep 27, 2014

SMP Linux on a SINGLE core in a dual core CPU

In recent posts on buildroot generated root file system and NFS RFS, I got a uClinux running on the Zedboard (rev c), which has dual ARM Cortex A9 cores in the Zynq 7020 CPU package.  Looking at /proc/cpuinfo confirms that Linux kernel is running on both cores.  But I want to use a core on a multi-core platform for hard real-time SW, so in this blog entry I will study running uClinux on a single core.

Perhaps a dozen years ago or so, the whole computer industry made the difficult transition to multi-core HW and SW.  Back then, I had to configure SMP explictly; now, I have to explicitly configure to NOT use all the cores in the HW!  Thesedays, I am not even sure if Linux is even tested on a single core in a multi-core platform, so the 1st thing I try is adding the "maxcpus=1" u-boot bootarg, like this:
setenv bootargs 'console=ttyPS0,115200 root=/dev/nfs ip=192.168.1.9 nfsroot=192.168.1.2:/export/root/zed rw earlyprintk maxcpus=1'

boot

Unfortunately, the kernel froze:
SMP: Total of 1 processors activated.
CPU: All CPU(s) started in SVC mode.
...
io scheduler noop registered
io scheduler deadline registered

io scheduler cfq registered (default)
I googled around for "Zynq maxcpus=1 hang" and found other people having similar but not quite the same problems in this forum, and slept on the problem.  But when I woke up and tried it again, the kernel started up without a problem and gave me a login prompt!  And it kept working without a problem since.  The number of CPUs is verified with this command
$ cat /proc/cpuinfo

I was thinking about letting Linux boot all CPUs and then powering off the last CPU with this kind of command, but I guess I won't need it for now.
$ echo 0 >> /sys/devices/system/cpu/cpu1/online

No comments:

Post a Comment