cvs commit: src/sys/i386/i386 pmap.c

Robert Watson rwatson at FreeBSD.org
Tue Nov 9 21:11:08 GMT 2004


On Tue, 9 Nov 2004, Stephan Uphoff wrote:

> > Can you explain why a spin mutex is more expensive than a sleep mutex (I 
> > assume this is uncontested)?
> 
> cli() and sti() used for the critical section are expensive.  ( The spin
> mutex includes the critical section) 
> 
> I recall a USENIX paper about avoiding the cost of cli(),sti() by just
> setting an in memory flag. The interrupt handler was modified to honor
> the flag and delay interrupt processing until the flag was cleared. 
> This may have the potential to drastically decrease the cost of a spin
> mutex if interrupts during critical regions are infrequent. 

This is present in FreeBSD 4.x, where spls use soft interrupt levels
rather than hardware disabling of interrupts.  It's also present in John's
jhb_lock branch, which hopefully he will merge soon.  It gets critical
section enter/exit, with the exception of around spinlocks, down to about
30-40 cycles on the P4.  I have a modified version of UMA in the
rwatson_percpu branch that uses critical sections instead of mutexes to
protect the per-CPU caches, which presumably makes the most sense when
combined with optimized critical sections once that's committed.  FWIW,
although it all micro-benchmarks much faster, I haven't yet demonstrated
that combining the light-weight critical sections with critical sections
around UMA per-CPU caches actually runs faster.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Principal Research Scientist, McAfee Research



More information about the cvs-src mailing list