DragonFly kernel List (threaded) for 2005-11
lockmgr interlock spinlock conversion patch #1
This patch converts the lock manager's interlock from a token to a
spinlock. This will theoretically fix the race condition that I had to
work around in kern/vfs_bio.c rev 1.52.
The race condition workaround prints two messages to the console if the
race occurs. It is my hope that this patch will result in these warning
messages no longer occuring:
"getnewbuf: warning, locked buf %p, race corrected"
"getnewbuf: warning, BUF_LOCK blocked unexpectedly on buf %p..."
I have also come up with a solution to implement the equivalent of
FreeBSD's msleep() (interlocked sleep with release of mutex). Due
to the cpu-locality-of-reference abstraction that DragonFly uses, there
is an ULTRA NIFTY shortcut that DragonFly can take. All DragonFly
needs to do is set the cpumask bit in the tsleep/wakeup hash table to
ensure that a wakeup() being called on another cpu sends an IPI message
to our cpu. The critical section we hold then protects us from processing
the IPI message too early, allowing us to enter the tsleep() after
releasing the resource without any possibility of a race. So:
tsleep_interlock(ident); /* set cpumask in hash table */
<--------- wakeup from another cpu can occur here
<--------- but processing of the wakeup is defered
to here due to our critical section.
It is yet another example of the advantages of using a
cpu-locality-of-reference model for safe MP operation instead of a