Sunday, September 5, 2010

Enabling Multiple CPUs (SMP)

Many of today’s computers have multiple CPUs. Some are physically distinct and others are virtual, such as hyperthreading and dual-core CPUs. In any case, these processors support symmetric multiprocessing (SMP) and can dramatically speed up Linux.

The kernel supports multiple CPUs and hyperthreading. If your computer has two CPUs that both support hyperthreading, the system will appear to have a total of four CPUs.

Older versions of Ubuntu, such as Hoary and Breezy, had different kernels available for SMP. To take advantage of multiple processors, you would need to install the appropriate kernel.

sudo apt-get install kernel-image-2.4.27-2-686-smp

Without installing an SMP kernel, you would only use one CPU on an SMP system.

Dapper Drake (6.06 LTS) changed this requirement. Under Dapper, all of the default kernels have SMP support enabled. The developers found that there was no significant speed impact from using an SMP kernel on a non-SMP system, and this simplified the number of kernels they needed to maintain.

There are a couple of ways to tell if your SMP processors are enabled in both the system hardware and kernel:

• /proc/cpuinfo—This file contains a list of all CPUs on the system. Alternately, you can use sudo lshw -class cpu.

• top—The top command shows what processes are running. If you run top and press 1, the header provides a list of all CPUs individually and their individual CPU loads. (This is really fun when running it on a system with 32 CPUs. Make sure the terminal window is tall enough to prevent scrolling!)

• System Monitor—The SystemMonitor applet can be added to the Gnome panels.When you click it, it shows the differentCPUloads.

In each of these cases, if only one CPU is listed, then you are not running SMP. Multiple CPUs in the listings indicate SMP mode.



Disabling SMP
In some situations, such as application benchmarking or hardware debugging, you may want to disable SMP support. This can be done with the kernel parameters nosmp or maxcpus=1. If this is a temporary need, then you can boot the system, catch GRUB at the menu by pressing Esc, and enter boot nosmp maxcpus=1 at the prompt. If you have multiple boot options, then you may need to edit the kernel line and add nosmp maxcpus=1 to the kernel boot line.

Some kernels may not work with nosmp, but in my experience maxcpus=1 always works.

The default boot loader gives you three seconds to press the escape key before it boots the operating system.



Missing SMP?
If you find that you only have one active CPU on a multiple CPU system, then there are few generic debugging options. The problem is unlikely to be related to Ubuntu—it is probably a general Linux kernel problem.

• Check with the motherboard’s manufacturer to see if Linux supports the chipset. For example, I have an old dual-CPU motherboard that is not supported by Linux.

• Check the Linux Hardware FAQ for the motherboard or chipset. This will tell you if other people managed to get it to work. Web sites such as https://wiki.ubuntu.com/HardwareSupport and www.faqs.org/docs/Linux-HOWTO/SMP-HOWTO.html are good places to start.

• If all else fails, post a query to any of the Linux or Ubuntu hardware forums. Maybe someone else knows a workaround. Some good forums include ubuntuforums.org, www.linuxhardware.org, and www.linuxforums.org. Be sure to include details such as the make and model of the motherboard, Ubuntu version, and other peripherals. It is generally better to provide too much information when asking for help, rather than too little.

Unfortunately, if SMP is not enabled after the basic installation, then it probably will not work. But you might get lucky—if someone has a patch, then you will probably need to recompile the kernel.

Compiling the kernel is not for the weak-of-heart. Many aspects of Linux are now automated or have easy-to-use graphical interfaces, but compiling the kernel is not one of them. There are plenty of help pages and FAQs for people daring enough to compile their own kernel.

Source of Information : Wiley Ubuntu Powerful Hacks And Customizations

No comments: