The FreeBSD Diary |
(TM) | Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link. |
SMP - using more than one CPU
5 November 2000
|
This rather short article is all about adding SMP to your kernel.
Technically, SMP is symmetric
multiprocessing. Practically, it means having more than one CPU. Such
machines are faster than single CPU machines. In this article, I will assume you have a dual-cpu box. It's not hard to expand this section to apply to more CPUs, but I'm not going to guess at exactly how that is done. FreeBSD, by default, does not have SMP enable in the kernel. This means that FreeBSD sees only the first CPU. In order to enable the other CPU[s], you need to create a new kernel. For instructions on how to create a new kernel, refer to the Configuring the FreeBSD Kernel section in the FreeBSD handbook. Pay special attention to the section on Building and Installing a Custom Kernel. I created my new kernel, using the above instructions, by searching for SMP within my kernel configuration file. I found this: # To make an SMP kernel, the next two are needed options SMP # Symmetric MultiProcessor Kernel options APIC_IO # Symmetric (APIC) I/O Those are the only options I added to my kernel. No other changes where made. For the record, the make took about 8 minutes, I think. Not sure. I wasn't timing it properly. |
Verifying that SMP is working
|
Here's what you should see near the end of your dmesg output:SMP: AP CPU #1 Launched! That's your second CPU. Also, if you look at top, you'll see a new column (C), which indicates which CPU a particluar process is running on: last pid: 171; load averages: 0.00, 0.00, 0.00 up 0+00:06:32 00:48:30 20 processes: 1 running, 19 sleeping CPU states: 0.0% user, 0.0% nice, 1.5% system, 0.0% interrupt, 98.5% idle Mem: 3552K Active, 4556K Inact, 4136K Wired, 8K Cache, 3840K Buf, 47M Free Swap: 132M Total, 132M Free PID USERNAME PRI NICE SIZE RES STATE C TIME WCPU CPU COMMAND 171 dan 28 0 1856K 1128K CPU0 0 0:00 1.75% 0.24% top 160 dan 10 0 1012K 808K wait 1 0:00 0.00% 0.00% bash 80 root 2 0 908K 612K select 0 0:00 0.00% 0.00% syslogd 159 root 2 0 1216K 904K select 1 0:00 0.00% 0.00% telnetd 113 root 2 0 1036K 768K select 1 0:00 0.00% 0.00% inetd 151 root 3 0 920K 636K ttyin 0 0:00 0.00% 0.00% getty 157 root 3 0 920K 636K ttyin 1 0:00 0.00% 0.00% getty 156 root 3 0 920K 636K ttyin 0 0:00 0.00% 0.00% getty 154 root 3 0 920K 636K ttyin 0 0:00 0.00% 0.00% getty 152 root 3 0 920K 636K ttyin 1 0:00 0.00% 0.00% getty 153 root 3 0 920K 636K ttyin 1 0:00 0.00% 0.00% getty 118 root 2 0 1524K 1316K select 1 0:00 0.00% 0.00% sendmail 158 root 3 0 920K 636K ttyin 0 0:00 0.00% 0.00% getty 155 root 3 0 920K 636K ttyin 1 0:00 0.00% 0.00% getty 115 root 10 0 948K 712K nanslp 1 0:00 0.00% 0.00% cron 83 daemon 2 0 912K 492K select 1 0:00 0.00% 0.00% portmap |