Date: Tue, 9 Nov 2004 21:09:55 +0000 (GMT) From: Robert Watson <rwatson@FreeBSD.org> To: Stephan Uphoff <ups@tree.com> Cc: Julian Elischer <julian@elischer.org> Subject: Re: cvs commit: src/sys/i386/i386 pmap.c Message-ID: <Pine.NEB.3.96L.1041109210808.60848B-100000@fledge.watson.org> In-Reply-To: <1100024464.29384.30.camel@palm.tree.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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@fledge.watson.org Principal Research Scientist, McAfee Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1041109210808.60848B-100000>