kern_lock.c (182010) | kern_lock.c (182914) |
---|---|
1/*- 2 * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 * DAMAGE. 27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 * DAMAGE. 27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/kern/kern_lock.c 182010 2008-08-22 16:14:23Z jhb $"); | 32__FBSDID("$FreeBSD: head/sys/kern/kern_lock.c 182914 2008-09-10 19:13:30Z jhb $"); |
33 34#include <sys/param.h> 35#include <sys/ktr.h> 36#include <sys/lock.h> 37#include <sys/lock_profile.h> 38#include <sys/lockmgr.h> 39#include <sys/mutex.h> 40#include <sys/proc.h> --- 329 unchanged lines hidden (view full) --- 370 if (op == LK_SHARED && (lk->lock_object.lo_flags & LK_NOSHARE)) 371 op = LK_EXCLUSIVE; 372 373 wakeup_swapper = 0; 374 switch (op) { 375 case LK_SHARED: 376 if (LK_CAN_WITNESS(flags)) 377 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER, | 33 34#include <sys/param.h> 35#include <sys/ktr.h> 36#include <sys/lock.h> 37#include <sys/lock_profile.h> 38#include <sys/lockmgr.h> 39#include <sys/mutex.h> 40#include <sys/proc.h> --- 329 unchanged lines hidden (view full) --- 370 if (op == LK_SHARED && (lk->lock_object.lo_flags & LK_NOSHARE)) 371 op = LK_EXCLUSIVE; 372 373 wakeup_swapper = 0; 374 switch (op) { 375 case LK_SHARED: 376 if (LK_CAN_WITNESS(flags)) 377 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER, |
378 file, line); | 378 file, line, ilk); |
379 for (;;) { 380 x = lk->lk_lock; 381 382 /* 383 * If no other thread has an exclusive lock, or 384 * no exclusive waiter is present, bump the count of 385 * sharers. Since we have to preserve the state of 386 * waiters, if we fail to acquire the shared lock --- 113 unchanged lines hidden (view full) --- 500 * give up the shared lock. 501 */ 502 wakeup_swapper |= wakeupshlk(lk, file, line); 503 504 /* FALLTHROUGH */ 505 case LK_EXCLUSIVE: 506 if (LK_CAN_WITNESS(flags)) 507 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER | | 379 for (;;) { 380 x = lk->lk_lock; 381 382 /* 383 * If no other thread has an exclusive lock, or 384 * no exclusive waiter is present, bump the count of 385 * sharers. Since we have to preserve the state of 386 * waiters, if we fail to acquire the shared lock --- 113 unchanged lines hidden (view full) --- 500 * give up the shared lock. 501 */ 502 wakeup_swapper |= wakeupshlk(lk, file, line); 503 504 /* FALLTHROUGH */ 505 case LK_EXCLUSIVE: 506 if (LK_CAN_WITNESS(flags)) 507 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER | |
508 LOP_EXCLUSIVE, file, line); | 508 LOP_EXCLUSIVE, file, line, ilk); |
509 510 /* 511 * If curthread already holds the lock and this one is 512 * allowed to recurse, simply recurse on it. 513 */ 514 if (lockmgr_xlocked(lk)) { 515 if ((flags & LK_CANRECURSE) == 0 && 516 (lk->lock_object.lo_flags & LK_CANRECURSE) == 0) { --- 202 unchanged lines hidden (view full) --- 719 sleepq_release(&lk->lock_object); 720 break; 721 } else 722 wakeup_swapper = wakeupshlk(lk, file, line); 723 break; 724 case LK_DRAIN: 725 if (LK_CAN_WITNESS(flags)) 726 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER | | 509 510 /* 511 * If curthread already holds the lock and this one is 512 * allowed to recurse, simply recurse on it. 513 */ 514 if (lockmgr_xlocked(lk)) { 515 if ((flags & LK_CANRECURSE) == 0 && 516 (lk->lock_object.lo_flags & LK_CANRECURSE) == 0) { --- 202 unchanged lines hidden (view full) --- 719 sleepq_release(&lk->lock_object); 720 break; 721 } else 722 wakeup_swapper = wakeupshlk(lk, file, line); 723 break; 724 case LK_DRAIN: 725 if (LK_CAN_WITNESS(flags)) 726 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER | |
727 LOP_EXCLUSIVE, file, line); | 727 LOP_EXCLUSIVE, file, line, ilk); |
728 729 /* 730 * Trying to drain a lock we already own will result in a 731 * deadlock. 732 */ 733 if (lockmgr_xlocked(lk)) { 734 if (flags & LK_INTERLOCK) 735 class->lc_unlock(ilk); --- 342 unchanged lines hidden --- | 728 729 /* 730 * Trying to drain a lock we already own will result in a 731 * deadlock. 732 */ 733 if (lockmgr_xlocked(lk)) { 734 if (flags & LK_INTERLOCK) 735 class->lc_unlock(ilk); --- 342 unchanged lines hidden --- |