subr_witness.c (87593) | subr_witness.c (88088) |
---|---|
1/*- 2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 26 * SUCH DAMAGE. 27 * 28 * from BSDI $Id: mutex_witness.c,v 1.1.2.20 2000/04/27 03:10:27 cp Exp $ 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ | 1/*- 2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 26 * SUCH DAMAGE. 27 * 28 * from BSDI $Id: mutex_witness.c,v 1.1.2.20 2000/04/27 03:10:27 cp Exp $ 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ |
30 * $FreeBSD: head/sys/kern/subr_witness.c 87593 2001-12-10 05:40:12Z obrien $ | 30 * $FreeBSD: head/sys/kern/subr_witness.c 88088 2001-12-18 00:27:18Z jhb $ |
31 */ 32 33/* 34 * Implementation of the `witness' lock verifier. Originally implemented for 35 * mutexes in BSD/OS. Extended to handle generic lock objects and lock 36 * classes in FreeBSD. 37 */ 38 --- 208 unchanged lines hidden (view full) --- 247 248static struct mtx all_mtx = { 249 { &lock_class_mtx_sleep, /* mtx_object.lo_class */ 250 "All locks list", /* mtx_object.lo_name */ 251 LO_INITIALIZED, /* mtx_object.lo_flags */ 252 { NULL }, /* mtx_object.lo_list */ 253 NULL }, /* mtx_object.lo_witness */ 254 MTX_UNOWNED, 0, /* mtx_lock, mtx_recurse */ | 31 */ 32 33/* 34 * Implementation of the `witness' lock verifier. Originally implemented for 35 * mutexes in BSD/OS. Extended to handle generic lock objects and lock 36 * classes in FreeBSD. 37 */ 38 --- 208 unchanged lines hidden (view full) --- 247 248static struct mtx all_mtx = { 249 { &lock_class_mtx_sleep, /* mtx_object.lo_class */ 250 "All locks list", /* mtx_object.lo_name */ 251 LO_INITIALIZED, /* mtx_object.lo_flags */ 252 { NULL }, /* mtx_object.lo_list */ 253 NULL }, /* mtx_object.lo_witness */ 254 MTX_UNOWNED, 0, /* mtx_lock, mtx_recurse */ |
255 0, /* mtx_savecrit */ | |
256 TAILQ_HEAD_INITIALIZER(all_mtx.mtx_blocked), 257 { NULL, NULL } /* mtx_contested */ 258}; 259 260/* 261 * This global is set to 0 once it becomes safe to use the witness code. 262 */ 263static int witness_cold = 1; --- 567 unchanged lines hidden (view full) --- 831 CTR4(KTR_WITNESS, 832 "%s: pid %d unrecursed on %s r=%d", __func__, 833 td->td_proc->p_pid, 834 instance->li_lock->lo_name, 835 instance->li_flags); 836 instance->li_flags--; 837 goto out; 838 } | 255 TAILQ_HEAD_INITIALIZER(all_mtx.mtx_blocked), 256 { NULL, NULL } /* mtx_contested */ 257}; 258 259/* 260 * This global is set to 0 once it becomes safe to use the witness code. 261 */ 262static int witness_cold = 1; --- 567 unchanged lines hidden (view full) --- 830 CTR4(KTR_WITNESS, 831 "%s: pid %d unrecursed on %s r=%d", __func__, 832 td->td_proc->p_pid, 833 instance->li_lock->lo_name, 834 instance->li_flags); 835 instance->li_flags--; 836 goto out; 837 } |
839 s = critical_enter(); | 838 s = cpu_critical_enter(); |
840 CTR4(KTR_WITNESS, 841 "%s: pid %d removed %s from lle[%d]", __func__, 842 td->td_proc->p_pid, 843 instance->li_lock->lo_name, 844 (*lock_list)->ll_count - 1); 845 (*lock_list)->ll_count--; 846 for (j = i; j < (*lock_list)->ll_count; j++) 847 (*lock_list)->ll_children[j] = 848 (*lock_list)->ll_children[j + 1]; | 839 CTR4(KTR_WITNESS, 840 "%s: pid %d removed %s from lle[%d]", __func__, 841 td->td_proc->p_pid, 842 instance->li_lock->lo_name, 843 (*lock_list)->ll_count - 1); 844 (*lock_list)->ll_count--; 845 for (j = i; j < (*lock_list)->ll_count; j++) 846 (*lock_list)->ll_children[j] = 847 (*lock_list)->ll_children[j + 1]; |
849 critical_exit(s); | 848 cpu_critical_exit(s); |
850 if ((*lock_list)->ll_count == 0) { 851 lle = *lock_list; 852 *lock_list = lle->ll_next; 853 CTR3(KTR_WITNESS, 854 "%s: pid %d removed lle %p", __func__, 855 td->td_proc->p_pid, lle); 856 witness_lock_list_free(lle); 857 } --- 33 unchanged lines hidden (view full) --- 891 892 if (witness_dead || panicstr != NULL) 893 return (0); 894 KASSERT(!witness_cold, ("%s: witness_cold", __func__)); 895 n = 0; 896 /* 897 * Preemption bad because we need PCPU_PTR(spinlocks) to not change. 898 */ | 849 if ((*lock_list)->ll_count == 0) { 850 lle = *lock_list; 851 *lock_list = lle->ll_next; 852 CTR3(KTR_WITNESS, 853 "%s: pid %d removed lle %p", __func__, 854 td->td_proc->p_pid, lle); 855 witness_lock_list_free(lle); 856 } --- 33 unchanged lines hidden (view full) --- 890 891 if (witness_dead || panicstr != NULL) 892 return (0); 893 KASSERT(!witness_cold, ("%s: witness_cold", __func__)); 894 n = 0; 895 /* 896 * Preemption bad because we need PCPU_PTR(spinlocks) to not change. 897 */ |
899 savecrit = critical_enter(); | 898 savecrit = cpu_critical_enter(); |
900 td = curthread; 901 lock_list = &td->td_sleeplocks; 902again: 903 for (lle = *lock_list; lle != NULL; lle = lle->ll_next) 904 for (i = lle->ll_count - 1; i >= 0; i--) { 905 lock1 = &lle->ll_children[i]; 906 if (lock1->li_lock == lock || 907 lock1->li_lock == &Giant.mtx_object) --- 18 unchanged lines hidden (view full) --- 926 if (lock_list == &td->td_sleeplocks) { 927 lock_list = PCPU_PTR(spinlocks); 928 goto again; 929 } 930#ifdef DDB 931 if (witness_ddb && n) 932 Debugger(__func__); 933#endif /* DDB */ | 899 td = curthread; 900 lock_list = &td->td_sleeplocks; 901again: 902 for (lle = *lock_list; lle != NULL; lle = lle->ll_next) 903 for (i = lle->ll_count - 1; i >= 0; i--) { 904 lock1 = &lle->ll_children[i]; 905 if (lock1->li_lock == lock || 906 lock1->li_lock == &Giant.mtx_object) --- 18 unchanged lines hidden (view full) --- 925 if (lock_list == &td->td_sleeplocks) { 926 lock_list = PCPU_PTR(spinlocks); 927 goto again; 928 } 929#ifdef DDB 930 if (witness_ddb && n) 931 Debugger(__func__); 932#endif /* DDB */ |
934 critical_exit(savecrit); | 933 cpu_critical_exit(savecrit); |
935 return (n); 936} 937 938static struct witness * 939enroll(const char *description, struct lock_class *lock_class) 940{ 941 struct witness *w; 942 --- 412 unchanged lines hidden (view full) --- 1355 * td->td_kse->ke_oncpu to get the list of spinlocks for this thread 1356 * and "fix" this. 1357 */ 1358 if (td == curthread) { 1359 /* 1360 * Preemption bad because we need PCPU_PTR(spinlocks) to not 1361 * change. 1362 */ | 934 return (n); 935} 936 937static struct witness * 938enroll(const char *description, struct lock_class *lock_class) 939{ 940 struct witness *w; 941 --- 412 unchanged lines hidden (view full) --- 1354 * td->td_kse->ke_oncpu to get the list of spinlocks for this thread 1355 * and "fix" this. 1356 */ 1357 if (td == curthread) { 1358 /* 1359 * Preemption bad because we need PCPU_PTR(spinlocks) to not 1360 * change. 1361 */ |
1363 savecrit = critical_enter(); | 1362 savecrit = cpu_critical_enter(); |
1364 nheld += witness_list_locks(PCPU_PTR(spinlocks)); | 1363 nheld += witness_list_locks(PCPU_PTR(spinlocks)); |
1365 critical_exit(savecrit); | 1364 cpu_critical_exit(savecrit); |
1366 } 1367 return (nheld); 1368} 1369 1370void 1371witness_save(struct lock_object *lock, const char **filep, int *linep) 1372{ 1373 struct lock_instance *instance; --- 132 unchanged lines hidden --- | 1365 } 1366 return (nheld); 1367} 1368 1369void 1370witness_save(struct lock_object *lock, const char **filep, int *linep) 1371{ 1372 struct lock_instance *instance; --- 132 unchanged lines hidden --- |