knowing which locks would rock.
i imagine the easiest way to find out would be modify lock() to bump a
per-lock ctr on failure-to-acquire. on i386 lock add would be the easiest
way to do that, i think. add an 'inited' field to the spinlock and a list
linkage as well, to allow for easy examination when you hit the system with
acid.
also if the locks in question need to be locked and the resources they
protect cannot be split, we can do much better than our current spinlocks:
void lock(int *l) {
int old = __sync_fetch_and_add(l, 1);
short next,owner;
do {
next = old & 0x0000FFFF;
owner = (old >> 16) & 0x0000FFFF;
old = *l;
} while(next != owner);
}
void unlock(int *l) {
__sync_fetch_and_add(l, (1 << 16));
}
(this is in gcc-C, but porting wouldn't be bad; the unlock
__sync_fetch_and_add would be LOCK ADD on i386. the __sync_fetch_and_add in
lock would be LOCK XADD on i386. i don't know 8a's syntax well enough to do
this right, in particular how 8a's pseudoregs work).
(many credits to nick piggin for this lock design. its totally rad.)
-- vs