[TriLUG] kernel question

crimsun at fungus.sh.nu crimsun at fungus.sh.nu
Tue Jul 15 14:00:04 EDT 2003


On Tue, Jul 15, 2003 at 10:43:45AM -0400, Matt Hoover wrote:
> The good news is that a SMP kernel will work fine on a
> Uniprocessor system.  The bad news is that there is a 
> performance hit.  

True. The better news is that the overhead isn't _too_ bad.

> locking on SMP.  On a Uniprocessor system, the kernel can 
> disable interrupts, and be assured that nothing else is going 
> to modify memory.  But on a SMP system, another processor 
> can modify memory.  So the solution is to add locks (often 
> called spinlocks) for various parts of memory.  What happens 
> is when a processor wants to access memory protected by a 
> lock, it first gets the lock.  In order to get the lock, 
> the processor goes into a tight loop until the lock is available.  
> Once it has acquired the lock, it accesses the memory, and 
> then releases the lock so other processors can get it.  Acquiring 

Applies to any resource in contention, but I presume you were just
using memory as an example. Spinlocks are just one form; there are also
mutexes and futexes. The latter was fairly recently (in the age of
Linux, that is) introduced, and the trend has been to proceed from
fairly heavy-handed locking in 2.0 for SMP to more and more fine-
grained, albeit more complex, locking in 2.4 and 2.6. The complexity is
just one of the prices we monolithic kernel users have to pay (as
opposed to say, the microkernel type of QNX); then again we have more
efficient sharing of driver resources like caches.

> One other thing to note is that this applies to the 2.4.x and 2.2.x
> series kernels.  In 2.5.x, and now 2.6.x, pre-emption support has
> been added to the kernel.  Therefore, spinlocks are needed even
> on a Uniprocessor system (if pre-emption has been enabled in the
> config)

Which all goes to say that Greg, while you're perfectly safe running a
SMP kernel on a UP machine, the decision to recompile really is an
afterthought. In my mind there are two things to consider:

1) overhead of running SMP
2) catching SMP bugs :)  [what?! Do you mean they exist?!]

The moral of the story being that you're A-OK until your next upgrade.

-- 
Daniel T. Chen          crimsun at fungus.sh.nu
GPG key:   www.sh.nu/~crimsun/pubkey.gpg.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://www.trilug.org/pipermail/trilug/attachments/20030715/e13985f3/attachment.pgp>


More information about the TriLUG mailing list