Other pages in this wiki describe how, for many multi-cpu/multi-core computers (but not necessarily all; a trial-and-error approach is best), the realtime performance of LinuxCNC significantly improves if the linux-rtai kernel is invoked with the boot parameter isolcpus=n, where n is the last cpu (starting with 0, so a dual-core machine would use isolcpus=1).
For computers using classic GRUB as the boot manager, this is accomplished by editing the file /boot/grub/menu.lst to include the boot parameter "isolcpus=1" (for example) at the end of appropriate kernel lines.
The below entries were used to isolate cores 1,2,3 on a quad core processor, leaving core 0 doing all the work
title EMC2 - rtai kernel isolcpu Ubuntu 10.04 (on /dev/sdb7)
kernel /boot/vmlinuz-2.6.32-122-rtai root=UUID=42d5e8ad-507d-41ea-8ad6-868e87be2ed6 ro isolcpus=1,2,3
For LinuxCNC installations based on Ubuntu 9.10 (Karmic Karma) and above, however, the default boot manager is no longer classic GRUB but instead GRUB2 (confusingly, this refers to GRUB v1.90 and above). The situation is more complicated with GRUB2 because of the manner in which various configuration files dynamically contribute to the file /boot/grub/grub.cfg, which replaces menu.lst. In particular, the most transparent attempt to accomplish the same end is to edit the appropriate "isolcpus=1" parameter into the key string GRUB_CMDLINE_LINUX_DEFAULT in the file /etc/default/grub, but this results in all linux kernel boot options being so marked, even if one has installed multiple linux kernels, some of which one wishes to use with all available cpus (for example, for CAD work).
This situation has been discussed at length on the linuxcnc-users email list in late March/early April 2011. The following is the solution I proposed. There are other possible solutions, and I recommend reading the email archive.
As shipped, Ubuntu distributions using GRUB2 include a set of configuration script files in the directory /etc/grub.d/ with names 00_header, 05_debian_theme, 10_linux, etc. These files are processed in numerical order as a component of GRUB2 creates the file grub.cfg. My solution is to add to this directory a new file 07_rtai that scans for linux-rtai kernels and for them only creates boot menu entries including the "isolcpus=1" parameter. I have uploaded a copy of this file at [[07_rtai]].
Assuming one has downloaded this file to one's home directory, the following commands will implement it.
<username>@<hostname>$ sudo cp 07_rtai /etc/grub.d
<username>@<hostname>$ sudo chmod +x /etc/grub.d/07_rtai
<username>@<hostname>$ sudo update-grub
At this point, one should find that the file /boot/grub/grub.cfg contains menu entries for the linux-rtai kernels with the boot parameter "isolcpus=1" set at the end of the kernel line. If the default file 10_linux is present and executable, the same linux-rtai kernels as well as all other installed linux kernels will also occur in following menu entries without this additional parameter present.
I created the file 07_rtai by editing a copy of the distributed file 10_linux. Following my introductory block of comments, all changes to the logic of 10_linux have been marked in 07_rtai by comment lines beginning #KAR:.
Two points to note are
1. The way GRUB2 works, I was not free to define my own keys, such as GRUB_CMDLINE_LINUX_RTAI and ISOLCPUS, in the file /etc/default/grub and expect them to be passed into 07_rtai as it is being created. This means one may need to edit two different files to modify what my work does. For example, if one wishes to change the boot menu entries so all linux kernels boot with no splash, one must edit the key GRUB_CMDLINE_LINUX_DEFAULT in the file /etc/default/grub. On the other hand, if one wishes to change the number of the highest cpu, then one must edit the string 'ISOCPUS="isolcpus=1"' defined early in the file /etc/grub.d/07_rtai. I'm truly sorry for this, but I can only blame the GRUB2 developers.
2. The default configuration of GRUB2 results in an immediate boot of the first linux kernel in the boot menu entries. With the addition of my file 07_rtai to a default Ubuntu distribution, this will be the latest version linux-rtai kernel GRUB2 found when creating the file /boot/grub/grub.cfg. During boot up, one can hold down the Shift-key while GRUB2 is starting to display the boot menu display, or one can edit the /etc/default/grub file to change GRUB2 behavior. Please see the GRUB2 manual or the appropriate Ubuntu forums.
This page was originally created by Kent Reed (aka cncdreamer) on 20110409.