On Wed, 2005-12-21 at 16:40 +1100, O Plameras wrote:
> #define spin_lock_init(lock)    do { (void)(lock); } while(0)
> #define _raw_spin_lock(lock)    do { (void)(lock); } while(0)
>  
> I am reading this cited macros. This is very very clear.
> 
> It is very very clear what it says, and, i.e., regardless of what
> is the value of 'lock' the kernel should do nothing.

That's exactly right. And if you compile without CONFIG_SMP, that's what
gets built into your kernel. You can get away with it because of the
clever way in which a CPU does one thing at a time; there is no "true"
parallelism.

If you compile *with* CONFIG_SMP, those definitions get preprocessed out
and some other macros get compiled in that do things like disable
interrupts, bus lock and do atomic writes and so forth, with the net
effect of implementing a spin lock.

If you install the -smp kernel on Ubuntu today, you get the version
compiled *with* CONFIG_SMP, and the code I cited will be compiled out
and substituted with this devious spin-lock implementing spin lock code.

Otherwise you don't, and (unsurprisingly) you get UP support, with no
spin locks, which you've verified for us with your insightful analysis
of those macros.

Jeff explained that right now Ubuntu ships only with the non-CONFIG_SMP
kernel on the CD due to space constraints *and* that subsequent releases
of Ubuntu have a solution to this UP/SMP problem in a single kernel
image. If I understand correctly, it's implemented with some runtime
function-table rewriting, which means you would only incur the cost of a
function call, rather than the bus-lock etc.

I hope that's clear.

James.


-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to