multiprocessors

Eric McCoy emccoy at haystacks.org
Thu Apr 7 06:23:23 PDT 2005


Bill wrote:
> On Wed, 2005-04-06 at 21:16, FreeBSD Deamon wrote:
>>Bill wrote:

>>>Is there a comand to use so as to see if freebsd is using both
>>>processors?

sysctl hw.ncpu, I think.

You can also look at /var/run/dmesg.boot and look for:

FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
  cpu0 (BSP): APIC ID:  1
  cpu1 (AP): APIC ID:  0

BSP stands for bootstrap processor and AP for application processor. 
The BSP is the one used to load the system until this message comes up:

SMP: AP CPU #1 Launched!

which will happen right before the kernel launches init.

>>try top(1)
>>
>>the output of top should contain a "C" column. if this column contains 
>>"0"s and "1"s both your CPUs are used

> There is a line for cpu put it only shows one. Im used to linux and when
> I do a top in Linux I see two lines for my cpus.

You are looking in the wrong place.  A C *column*, not a CPU *row*. 
FreeBSD will only ever show the total CPU time on the CPU row.  This is 
something like what you will see on an SMP system:

   PID USERNAME PRI NICE   SIZE    RES STATE  C   TIME   WCPU    CPU COMMAND
89704 emccoy    96    0  2484K  1660K CPU1   0   0:00  0.51%  0.05% top
97005 root      96    0  3092K  1248K select 1  29:28  0.00%  0.00% ntpd

First, note the state for top: it's CPU1.  Second, the "C" column is 0 
for top, 1 for ntpd.  The "C" column is the last CPU the process ran on.

The WCPU and CPU columns, by the way, are both *per-CPU*, as you can see 
here:

CPU states:  2.7% user,  0.0% nice, 47.5% system,  0.8% interrupt, 49.0% 
idle
89739 emccoy   110    0  1324K   684K CPU0   0   0:43 99.00% 87.50% cat

So another way to tell if SMP is working is if the summary row says 50% 
idle but you've got a process which shows 100% active.

> Is the stock kernel that gets installed when doing a new install smp
> enabled?

No.

> Do i need to rebuild my kernel for smp?

Yes.  The good news is that it's very easy.  The Handbook has 
information on how to do it.  Basically all you need to do is add 
"options SMP" and make sure "device apic" is enabled (it is by default I 
believe, even for the GENERIC kernel).



More information about the freebsd-questions mailing list