Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_lock.c
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#endif | #endif | ||||
#ifdef HWPMC_HOOKS | #ifdef HWPMC_HOOKS | ||||
#include <sys/pmckern.h> | #include <sys/pmckern.h> | ||||
PMC_SOFT_DECLARE( , , lock, failed); | PMC_SOFT_DECLARE( , , lock, failed); | ||||
#endif | #endif | ||||
/* | |||||
* Hack. There should be prio_t or similar so that this is not necessary. | |||||
*/ | |||||
_Static_assert((PRILASTFLAG * 2) - 1 <= USHRT_MAX, | |||||
"prio flags wont fit in u_short pri in struct lock"); | |||||
CTASSERT(LK_UNLOCKED == (LK_UNLOCKED & | CTASSERT(LK_UNLOCKED == (LK_UNLOCKED & | ||||
~(LK_ALL_WAITERS | LK_EXCLUSIVE_SPINNERS))); | ~(LK_ALL_WAITERS | LK_EXCLUSIVE_SPINNERS))); | ||||
#define SQ_EXCLUSIVE_QUEUE 0 | #define SQ_EXCLUSIVE_QUEUE 0 | ||||
#define SQ_SHARED_QUEUE 1 | #define SQ_SHARED_QUEUE 1 | ||||
#ifndef INVARIANTS | #ifndef INVARIANTS | ||||
#define _lockmgr_assert(lk, what, file, line) | #define _lockmgr_assert(lk, what, file, line) | ||||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | sleeplk(struct lock *lk, u_int flags, struct lock_object *ilk, | ||||
pri &= PRIMASK; | pri &= PRIMASK; | ||||
error = 0; | error = 0; | ||||
LOCK_LOG3(lk, "%s: %p blocking on the %s sleepqueue", __func__, lk, | LOCK_LOG3(lk, "%s: %p blocking on the %s sleepqueue", __func__, lk, | ||||
(queue == SQ_EXCLUSIVE_QUEUE) ? "exclusive" : "shared"); | (queue == SQ_EXCLUSIVE_QUEUE) ? "exclusive" : "shared"); | ||||
if (flags & LK_INTERLOCK) | if (flags & LK_INTERLOCK) | ||||
class->lc_unlock(ilk); | class->lc_unlock(ilk); | ||||
if (queue == SQ_EXCLUSIVE_QUEUE && (flags & LK_SLEEPFAIL) != 0) | if (queue == SQ_EXCLUSIVE_QUEUE && (flags & LK_SLEEPFAIL) != 0) { | ||||
if (lk->lk_exslpfail < USHRT_MAX) | |||||
lk->lk_exslpfail++; | lk->lk_exslpfail++; | ||||
} | |||||
GIANT_SAVE(); | GIANT_SAVE(); | ||||
sleepq_add(&lk->lock_object, NULL, wmesg, SLEEPQ_LK | (catch ? | sleepq_add(&lk->lock_object, NULL, wmesg, SLEEPQ_LK | (catch ? | ||||
SLEEPQ_INTERRUPTIBLE : 0), queue); | SLEEPQ_INTERRUPTIBLE : 0), queue); | ||||
if ((flags & LK_TIMELOCK) && timo) | if ((flags & LK_TIMELOCK) && timo) | ||||
sleepq_set_timeout(&lk->lock_object, timo); | sleepq_set_timeout(&lk->lock_object, timo); | ||||
/* | /* | ||||
* Decisional switch for real sleeping. | * Decisional switch for real sleeping. | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | retry_sleepq: | ||||
* the real number of waiters with the LK_SLEEPFAIL flag on | * the real number of waiters with the LK_SLEEPFAIL flag on | ||||
* because they may be used in conjunction with interruptible | * because they may be used in conjunction with interruptible | ||||
* sleeps so lk_exslpfail might be considered an 'upper limit' | * sleeps so lk_exslpfail might be considered an 'upper limit' | ||||
* bound, including the edge cases. | * bound, including the edge cases. | ||||
*/ | */ | ||||
realexslp = sleepq_sleepcnt(&lk->lock_object, | realexslp = sleepq_sleepcnt(&lk->lock_object, | ||||
SQ_EXCLUSIVE_QUEUE); | SQ_EXCLUSIVE_QUEUE); | ||||
if ((x & LK_EXCLUSIVE_WAITERS) != 0 && realexslp != 0) { | if ((x & LK_EXCLUSIVE_WAITERS) != 0 && realexslp != 0) { | ||||
if (lk->lk_exslpfail < realexslp) { | if (lk->lk_exslpfail < realexslp) { | ||||
kib: Is this line too long now? | |||||
Done Inline ActionsIt is 84 if that's what you mean, but few lines below there is a 82 and in general the limit is rather soft at least in this file so I don't think this is a problem. mjg: It is 84 if that's what you mean, but few lines below there is a 82 and in general the limit is… | |||||
lk->lk_exslpfail = 0; | lk->lk_exslpfail = 0; | ||||
queue = SQ_EXCLUSIVE_QUEUE; | queue = SQ_EXCLUSIVE_QUEUE; | ||||
v |= (x & LK_SHARED_WAITERS); | v |= (x & LK_SHARED_WAITERS); | ||||
} else { | } else { | ||||
lk->lk_exslpfail = 0; | lk->lk_exslpfail = 0; | ||||
LOCK_LOG2(lk, | LOCK_LOG2(lk, | ||||
"%s: %p has only LK_SLEEPFAIL sleepers", | "%s: %p has only LK_SLEEPFAIL sleepers", | ||||
__func__, lk); | __func__, lk); | ||||
▲ Show 20 Lines • Show All 1,497 Lines • Show Last 20 Lines |
Is this line too long now?