SMP questions

Ivan Voras ivoras at freebsd.org
Thu Aug 28 14:45:48 UTC 2008


H.fazaeli wrote:
> 
> Hi all,
> I have 3 questions regrading SMP on freebsd 6.x:
> 
> 1. Is there any userland tool/api to bound a process to a specific cpu?

This support is native to 8-CURRENT, I think most of it is backported to
7.1.

> 2. Is there any way to force UP operation apart form recompiling kernel
>   without SMP option?

"mostly" - if you have a SMP kernel it will always use SMP locking and
scheduling algorithms, which are in 6.x somewhat slower than the UP
variants. You can force the kernel to use only one CPU with
machdep.hlt_cpus sysctl:

> sysctl -d machdep.hlt_cpus
machdep.hlt_cpus: Bitmap of CPUs to halt.  101 (binary) will halt CPUs 0
and 2.

(note that you have to give a decimal number to the sysctl)

> 3. Can someone shed some light on the logic of how schedulers (4.4.BSD/ULE)
>   dispatch processes among CPUs?

4.4BSD has a single queue of running threads from which the threads are
dispatched to CPUs when needed, in a way that's similar in effect to
round-robin. ULE has separate per-CPU queues and is aware of CPU
topologies so it knows that dispatching threads to cores on the same
physical CPU is better than picking a "distant" CPU. (this is all about
ULE in 7-STABLE and 8-CURRENT. ULE in 6.x is broken). This is why 4.4BSD
scales less well than ULE (but on the other hand 4.4BSD has had many
decades of hand optimizations and there are even now reports that it
behaves better in some edge circumstances).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080828/f59192aa/signature.pgp


More information about the freebsd-questions mailing list