<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [TriLUG] kernel question</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Darn required work email client :-(, sorry about the </FONT>
<BR><FONT SIZE=2>HTML mail.</FONT>
</P>

<P><FONT SIZE=2>Also, one other thing that I forgot to say, a lot of</FONT>
<BR><FONT SIZE=2>work goes into tuning spinlocks, so there are as</FONT>
<BR><FONT SIZE=2>efficient as possible (read hand crafted assembly),</FONT>
<BR><FONT SIZE=2>so the overhead is fairly low.</FONT>
<BR><FONT SIZE=2>--matt</FONT>
</P>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Matt Hoover [<A HREF="mailto:Matt.Hoover@haht.com">mailto:Matt.Hoover@haht.com</A>] </FONT>
<BR><FONT SIZE=2>Sent: Tuesday, July 15, 2003 10:44 AM</FONT>
<BR><FONT SIZE=2>To: 'trilug@trilug.org'</FONT>
<BR><FONT SIZE=2>Subject: RE: [TriLUG] kernel question</FONT>
</P>
<BR>

<P><FONT SIZE=2>The good news is that a SMP kernel will work fine on a </FONT>
<BR><FONT SIZE=2>Uniprocessor system.  The bad news is that there is a </FONT>
<BR><FONT SIZE=2>performance hit.  </FONT>
<BR><FONT SIZE=2>Now for those interested in the details, the reason for </FONT>
<BR><FONT SIZE=2>the performance hit is that the kernel has to do additional </FONT>
<BR><FONT SIZE=2>locking on SMP.  On a Uniprocessor system, the kernel can </FONT>
<BR><FONT SIZE=2>disable interrupts, and be assured that nothing else is going </FONT>
<BR><FONT SIZE=2>to modify memory.  But on a SMP system, another processor </FONT>
<BR><FONT SIZE=2>can modify memory.  So the solution is to add locks (often </FONT>
<BR><FONT SIZE=2>called spinlocks) for various parts of memory.  What happens </FONT>
<BR><FONT SIZE=2>is when a processor wants to access memory protected by a </FONT>
<BR><FONT SIZE=2>lock, it first gets the lock.  In order to get the lock, </FONT>
<BR><FONT SIZE=2>the processor goes into a tight loop until the lock is available.  </FONT>
<BR><FONT SIZE=2>Once it has acquired the lock, it accesses the memory, and </FONT>
<BR><FONT SIZE=2>then releases the lock so other processors can get it.  Acquiring </FONT>
<BR><FONT SIZE=2>and releasing locks has a certain amount of overhead, even if </FONT>
<BR><FONT SIZE=2>there are no other processors making the current processor wait </FONT>
<BR><FONT SIZE=2>for the lock.  So in the Uniprocessor kernel, where spinlocks </FONT>
<BR><FONT SIZE=2>aren't needed, the kernel replaces the get and release spinlock </FONT>
<BR><FONT SIZE=2>code with no-ops, which get optimized away. </FONT>
<BR><FONT SIZE=2>One other thing to note is that this applies to the 2.4.x and 2.2.x </FONT>
<BR><FONT SIZE=2>series kernels.  In 2.5.x, and now 2.6.x, pre-emption support has </FONT>
<BR><FONT SIZE=2>been added to the kernel.  Therefore, spinlocks are needed even </FONT>
<BR><FONT SIZE=2>on a Uniprocessor system (if pre-emption has been enabled in the </FONT>
<BR><FONT SIZE=2>config) </FONT>
<BR><FONT SIZE=2>> -----Original Message----- </FONT>
<BR><FONT SIZE=2>> From: Greg Brown [<A HREF="mailto:gregbrown@mindspring.com">mailto:gregbrown@mindspring.com</A>] </FONT>
<BR><FONT SIZE=2>> Sent: Tuesday, July 15, 2003 8:31 AM </FONT>
<BR><FONT SIZE=2>> To: trilug@trilug.org </FONT>
<BR><FONT SIZE=2>> Subject: [TriLUG] kernel question </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> If I accidently included symmetric multi-processing support into my </FONT>
<BR><FONT SIZE=2>> kernel on a machine which has only one processor.  By including this </FONT>
<BR><FONT SIZE=2>> option do I face and kind of a performance hit on my single processor </FONT>
<BR><FONT SIZE=2>> machine?  Even though I did include this option built-into my </FONT>
<BR><FONT SIZE=2>> kernel I </FONT>
<BR><FONT SIZE=2>> did not compile the kernel with options telling it to compile for N </FONT>
<BR><FONT SIZE=2>> number of processors.  I'm running the 2.4.21 kernel.  If the </FONT>
<BR><FONT SIZE=2>> kernel is </FONT>
<BR><FONT SIZE=2>> fine as-is I'll just leave well enough alone until I upgrade </FONT>
<BR><FONT SIZE=2>> again - if </FONT>
<BR><FONT SIZE=2>> not, I'll recompile.  Thoughts?  Anyone?  Bueller?  Fry? </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Greg </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> -- </FONT>
<BR><FONT SIZE=2>> TriLUG mailing list        : </FONT>
<BR><FONT SIZE=2>> <A HREF="http://www.trilug.org/mailman/listinfo/trilug" TARGET="_blank">http://www.trilug.org/mailman/listinfo/trilug</A> </FONT>
<BR><FONT SIZE=2>> TriLUG </FONT>
<BR><FONT SIZE=2>> Organizational FAQ  : <A HREF="http://trilug.org/faq/" TARGET="_blank">http://trilug.org/faq/</A> </FONT>
<BR><FONT SIZE=2>> TriLUG Member Services FAQ : <A HREF="http://members.trilug.org/services_faq/" TARGET="_blank">http://members.trilug.org/services_faq/</A> </FONT>
<BR><FONT SIZE=2>> TriLUG PGP Keyring         : <A HREF="http://trilug.org/~chrish/trilug.asc" TARGET="_blank">http://trilug.org/~chrish/trilug.asc</A> </FONT>
<BR><FONT SIZE=2>> </FONT>
</P>

</BODY>
</HTML>