diff options
| author | Jason Evans <jasone@FreeBSD.org> | 2000-09-09 23:18:48 +0000 |
|---|---|---|
| committer | Jason Evans <jasone@FreeBSD.org> | 2000-09-09 23:18:48 +0000 |
| commit | 5340642a2e3c32fa292b79e3461e41fa4ae20fee (patch) | |
| tree | 6858c8fe47198ad5d491dce2a46e094c8381a4b4 /sys/amd64/include | |
| parent | 46bf3fe5a66995faff2b208987d3deb599253efe (diff) | |
Notes
Diffstat (limited to 'sys/amd64/include')
| -rw-r--r-- | sys/amd64/include/mutex.h | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h index 6d63557eca2e..b19bfa9f7773 100644 --- a/sys/amd64/include/mutex.h +++ b/sys/amd64/include/mutex.h @@ -610,55 +610,50 @@ _mtx_enter(mtx_t *mtxp, int type, const char *file, int line) MPASS2(((type) & (MTX_NORECURSE | MTX_NOSWITCH)) == 0, STR_mtx_bad_type); - do { - if ((type) & MTX_SPIN) { + if ((type) & MTX_SPIN) { + /* + * Easy cases of spin locks: + * + * 1) We already own the lock and will simply recurse on it (if + * RLIKELY) + * + * 2) The lock is free, we just get it + */ + if ((type) & MTX_RLIKELY) { /* - * Easy cases of spin locks: - * - * 1) We already own the lock and will simply - * recurse on it (if RLIKELY) - * - * 2) The lock is free, we just get it + * Check for recursion, if we already have this + * lock we just bump the recursion count. */ - if ((type) & MTX_RLIKELY) { - /* - * Check for recursion, if we already - * have this lock we just bump the - * recursion count. - */ - if (mpp->mtx_lock == CURTHD) { - mpp->mtx_recurse++; - break; /* Done */ - } + if (mpp->mtx_lock == CURTHD) { + mpp->mtx_recurse++; + goto done; } + } - if (((type) & MTX_TOPHALF) == 0) { - /* - * If an interrupt thread uses this - * we must block interrupts here. - */ - if ((type) & MTX_FIRST) { - ASS_IEN; - disable_intr(); - _getlock_norecurse(mpp, CURTHD, - (type) & MTX_HARDOPTS); - } else { - _getlock_spin_block(mpp, CURTHD, - (type) & MTX_HARDOPTS); - } - } else + if (((type) & MTX_TOPHALF) == 0) { + /* + * If an interrupt thread uses this we must block + * interrupts here. + */ + if ((type) & MTX_FIRST) { + ASS_IEN; + disable_intr(); _getlock_norecurse(mpp, CURTHD, (type) & MTX_HARDOPTS); - } else { - /* Sleep locks */ - if ((type) & MTX_RLIKELY) - _getlock_sleep(mpp, CURTHD, - (type) & MTX_HARDOPTS); - else - _getlock_norecurse(mpp, CURTHD, + } else { + _getlock_spin_block(mpp, CURTHD, (type) & MTX_HARDOPTS); - } - } while (0); + } + } else + _getlock_norecurse(mpp, CURTHD, (type) & MTX_HARDOPTS); + } else { + /* Sleep locks */ + if ((type) & MTX_RLIKELY) + _getlock_sleep(mpp, CURTHD, (type) & MTX_HARDOPTS); + else + _getlock_norecurse(mpp, CURTHD, (type) & MTX_HARDOPTS); + } + done: WITNESS_ENTER(mpp, type, file, line); CTR5(KTR_LOCK, STR_mtx_enter_fmt, mpp->mtx_description, mpp, file, line, |
