kern_rwlock.c (244582) | kern_rwlock.c (251323) |
---|---|
1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@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 --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@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 --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 244582 2012-12-22 09:37:34Z attilio $"); | 35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 251323 2013-06-03 17:38:57Z jhb $"); |
36 37#include "opt_ddb.h" 38#include "opt_hwpmc_hooks.h" 39#include "opt_kdtrace.h" 40#include "opt_no_adaptive_rwlocks.h" 41 42#include <sys/param.h> 43#include <sys/kdb.h> --- 322 unchanged lines hidden (view full) --- 366 rw = rwlock2rw(c); 367 368 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), 369 ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d", 370 curthread, rw->lock_object.lo_name, file, line)); 371 KASSERT(rw->rw_lock != RW_DESTROYED, 372 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); 373 KASSERT(rw_wowner(rw) != curthread, | 36 37#include "opt_ddb.h" 38#include "opt_hwpmc_hooks.h" 39#include "opt_kdtrace.h" 40#include "opt_no_adaptive_rwlocks.h" 41 42#include <sys/param.h> 43#include <sys/kdb.h> --- 322 unchanged lines hidden (view full) --- 366 rw = rwlock2rw(c); 367 368 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread), 369 ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d", 370 curthread, rw->lock_object.lo_name, file, line)); 371 KASSERT(rw->rw_lock != RW_DESTROYED, 372 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line)); 373 KASSERT(rw_wowner(rw) != curthread, |
374 ("%s (%s): wlock already held @ %s:%d", __func__, | 374 ("rw_rlock: wlock already held for %s @ %s:%d", |
375 rw->lock_object.lo_name, file, line)); 376 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL); 377 378 for (;;) { 379#ifdef KDTRACE_HOOKS 380 spin_cnt++; 381#endif 382 /* --- 736 unchanged lines hidden (view full) --- 1119 1120 rw = rwlock2rw(c); 1121 1122 switch (what) { 1123 case RA_LOCKED: 1124 case RA_LOCKED | RA_RECURSED: 1125 case RA_LOCKED | RA_NOTRECURSED: 1126 case RA_RLOCKED: | 375 rw->lock_object.lo_name, file, line)); 376 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL); 377 378 for (;;) { 379#ifdef KDTRACE_HOOKS 380 spin_cnt++; 381#endif 382 /* --- 736 unchanged lines hidden (view full) --- 1119 1120 rw = rwlock2rw(c); 1121 1122 switch (what) { 1123 case RA_LOCKED: 1124 case RA_LOCKED | RA_RECURSED: 1125 case RA_LOCKED | RA_NOTRECURSED: 1126 case RA_RLOCKED: |
1127 case RA_RLOCKED | RA_RECURSED: 1128 case RA_RLOCKED | RA_NOTRECURSED: |
|
1127#ifdef WITNESS 1128 witness_assert(&rw->lock_object, what, file, line); 1129#else 1130 /* 1131 * If some other thread has a write lock or we have one 1132 * and are asserting a read lock, fail. Also, if no one 1133 * has a lock at all, fail. 1134 */ 1135 if (rw->rw_lock == RW_UNLOCKED || | 1129#ifdef WITNESS 1130 witness_assert(&rw->lock_object, what, file, line); 1131#else 1132 /* 1133 * If some other thread has a write lock or we have one 1134 * and are asserting a read lock, fail. Also, if no one 1135 * has a lock at all, fail. 1136 */ 1137 if (rw->rw_lock == RW_UNLOCKED || |
1136 (!(rw->rw_lock & RW_LOCK_READ) && (what == RA_RLOCKED || | 1138 (!(rw->rw_lock & RW_LOCK_READ) && (what & RA_RLOCKED || |
1137 rw_wowner(rw) != curthread))) 1138 panic("Lock %s not %slocked @ %s:%d\n", | 1139 rw_wowner(rw) != curthread))) 1140 panic("Lock %s not %slocked @ %s:%d\n", |
1139 rw->lock_object.lo_name, (what == RA_RLOCKED) ? | 1141 rw->lock_object.lo_name, (what & RA_RLOCKED) ? |
1140 "read " : "", file, line); 1141 | 1142 "read " : "", file, line); 1143 |
1142 if (!(rw->rw_lock & RW_LOCK_READ)) { | 1144 if (!(rw->rw_lock & RW_LOCK_READ) && !(what & RA_RLOCKED)) { |
1143 if (rw_recursed(rw)) { 1144 if (what & RA_NOTRECURSED) 1145 panic("Lock %s recursed @ %s:%d\n", 1146 rw->lock_object.lo_name, file, 1147 line); 1148 } else if (what & RA_RECURSED) 1149 panic("Lock %s not recursed @ %s:%d\n", 1150 rw->lock_object.lo_name, file, line); --- 80 unchanged lines hidden --- | 1145 if (rw_recursed(rw)) { 1146 if (what & RA_NOTRECURSED) 1147 panic("Lock %s recursed @ %s:%d\n", 1148 rw->lock_object.lo_name, file, 1149 line); 1150 } else if (what & RA_RECURSED) 1151 panic("Lock %s not recursed @ %s:%d\n", 1152 rw->lock_object.lo_name, file, line); --- 80 unchanged lines hidden --- |