summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sx.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-09-02 17:33:51 +0000
committerattilio <attilio@FreeBSD.org>2009-09-02 17:33:51 +0000
commitce3b4baf3c197905cedc13d17c7a220f68240510 (patch)
tree6d6740433b14bf13d7e3fd94a480ec836e8f5f6c /sys/kern/kern_sx.c
parent7cb9716a594877e05d088ad1c888a1b184340af0 (diff)
downloadFreeBSD-src-ce3b4baf3c197905cedc13d17c7a220f68240510.zip
FreeBSD-src-ce3b4baf3c197905cedc13d17c7a220f68240510.tar.gz
Fix some bugs related to adaptive spinning:
In the lockmgr support: - GIANT_RESTORE() is just called when the sleep finishes, so the current code can ends up into a giant unlock problem. Fix it by appropriately call GIANT_RESTORE() when needed. Note that this is not exactly ideal because for any interation of the adaptive spinning we drop and restore Giant, but the overhead should be not a factor. - In the lock held in exclusive mode case, after the adaptive spinning is brought to completition, we should just retry to acquire the lock instead to fallthrough. Fix that. - Fix a style nit In the sx support: - Call GIANT_SAVE() before than looping. This saves some overhead because in the current code GIANT_SAVE() is called several times. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
Diffstat (limited to 'sys/kern/kern_sx.c')
-rw-r--r--sys/kern/kern_sx.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index 4a78444..c00b267 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -531,13 +531,13 @@ _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, const char *file,
continue;
}
} else if (SX_SHARERS(x) && spintries < asx_retries) {
+ GIANT_SAVE();
spintries++;
for (i = 0; i < asx_loops; i++) {
if (LOCK_LOG_TEST(&sx->lock_object, 0))
CTR4(KTR_LOCK,
"%s: shared spinning on %p with %u and %u",
__func__, sx, spintries, i);
- GIANT_SAVE();
x = sx->sx_lock;
if ((x & SX_LOCK_SHARED) == 0 ||
SX_SHARERS(x) == 0)
OpenPOWER on IntegriCloud