subr_witness.c (227309) | subr_witness.c (227588) |
---|---|
1/*- 2 * Copyright (c) 2008 Isilon Systems, Inc. 3 * Copyright (c) 2008 Ilya Maykov <ivmaykov@gmail.com> 4 * Copyright (c) 1998 Berkeley Software Design, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 71 unchanged lines hidden (view full) --- 80 * you have two threads T1 and T2 and a sleepable lock X. Suppose that T1 81 * acquires X and blocks on Giant. Then suppose that T2 acquires Giant and 82 * blocks on X. When T2 blocks on X, T2 will release Giant allowing T1 to 83 * execute. Thus, acquiring Giant both before and after a sleepable lock 84 * will not result in a lock order reversal. 85 */ 86 87#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Isilon Systems, Inc. 3 * Copyright (c) 2008 Ilya Maykov <ivmaykov@gmail.com> 4 * Copyright (c) 1998 Berkeley Software Design, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 71 unchanged lines hidden (view full) --- 80 * you have two threads T1 and T2 and a sleepable lock X. Suppose that T1 81 * acquires X and blocks on Giant. Then suppose that T2 acquires Giant and 82 * blocks on X. When T2 blocks on X, T2 will release Giant allowing T1 to 83 * execute. Thus, acquiring Giant both before and after a sleepable lock 84 * will not result in a lock order reversal. 85 */ 86 87#include <sys/cdefs.h> |
88__FBSDID("$FreeBSD: head/sys/kern/subr_witness.c 227309 2011-11-07 15:43:11Z ed $"); | 88__FBSDID("$FreeBSD: head/sys/kern/subr_witness.c 227588 2011-11-16 21:51:17Z pjd $"); |
89 90#include "opt_ddb.h" 91#include "opt_hwpmc_hooks.h" 92#include "opt_stack.h" 93#include "opt_witness.h" 94 95#include <sys/param.h> 96#include <sys/bus.h> --- 230 unchanged lines hidden (view full) --- 327static void adopt(struct witness *parent, struct witness *child); 328#ifdef BLESSING 329static int blessed(struct witness *, struct witness *); 330#endif 331static void depart(struct witness *w); 332static struct witness *enroll(const char *description, 333 struct lock_class *lock_class); 334static struct lock_instance *find_instance(struct lock_list_entry *list, | 89 90#include "opt_ddb.h" 91#include "opt_hwpmc_hooks.h" 92#include "opt_stack.h" 93#include "opt_witness.h" 94 95#include <sys/param.h> 96#include <sys/bus.h> --- 230 unchanged lines hidden (view full) --- 327static void adopt(struct witness *parent, struct witness *child); 328#ifdef BLESSING 329static int blessed(struct witness *, struct witness *); 330#endif 331static void depart(struct witness *w); 332static struct witness *enroll(const char *description, 333 struct lock_class *lock_class); 334static struct lock_instance *find_instance(struct lock_list_entry *list, |
335 struct lock_object *lock); | 335 const struct lock_object *lock); |
336static int isitmychild(struct witness *parent, struct witness *child); 337static int isitmydescendant(struct witness *parent, struct witness *child); 338static void itismychild(struct witness *parent, struct witness *child); 339static int sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS); 340static int sysctl_debug_witness_watch(SYSCTL_HANDLER_ARGS); 341static int sysctl_debug_witness_fullgraph(SYSCTL_HANDLER_ARGS); 342static void witness_add_fullgraph(struct sbuf *sb, struct witness *parent); 343#ifdef DDB --- 1714 unchanged lines hidden (view full) --- 2058 2059 mtx_lock_spin(&w_mtx); 2060 lle->ll_next = w_lock_list_free; 2061 w_lock_list_free = lle; 2062 mtx_unlock_spin(&w_mtx); 2063} 2064 2065static struct lock_instance * | 336static int isitmychild(struct witness *parent, struct witness *child); 337static int isitmydescendant(struct witness *parent, struct witness *child); 338static void itismychild(struct witness *parent, struct witness *child); 339static int sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS); 340static int sysctl_debug_witness_watch(SYSCTL_HANDLER_ARGS); 341static int sysctl_debug_witness_fullgraph(SYSCTL_HANDLER_ARGS); 342static void witness_add_fullgraph(struct sbuf *sb, struct witness *parent); 343#ifdef DDB --- 1714 unchanged lines hidden (view full) --- 2058 2059 mtx_lock_spin(&w_mtx); 2060 lle->ll_next = w_lock_list_free; 2061 w_lock_list_free = lle; 2062 mtx_unlock_spin(&w_mtx); 2063} 2064 2065static struct lock_instance * |
2066find_instance(struct lock_list_entry *list, struct lock_object *lock) | 2066find_instance(struct lock_list_entry *list, const struct lock_object *lock) |
2067{ 2068 struct lock_list_entry *lle; 2069 struct lock_instance *instance; 2070 int i; 2071 2072 for (lle = list; lle != NULL; lle = lle->ll_next) 2073 for (i = lle->ll_count - 1; i >= 0; i--) { 2074 instance = &lle->ll_children[i]; --- 130 unchanged lines hidden (view full) --- 2205 class->lc_name, lock->lo_name); 2206 lock->lo_witness->w_file = file; 2207 lock->lo_witness->w_line = line; 2208 instance->li_file = file; 2209 instance->li_line = line; 2210} 2211 2212void | 2067{ 2068 struct lock_list_entry *lle; 2069 struct lock_instance *instance; 2070 int i; 2071 2072 for (lle = list; lle != NULL; lle = lle->ll_next) 2073 for (i = lle->ll_count - 1; i >= 0; i--) { 2074 instance = &lle->ll_children[i]; --- 130 unchanged lines hidden (view full) --- 2205 class->lc_name, lock->lo_name); 2206 lock->lo_witness->w_file = file; 2207 lock->lo_witness->w_line = line; 2208 instance->li_file = file; 2209 instance->li_line = line; 2210} 2211 2212void |
2213witness_assert(struct lock_object *lock, int flags, const char *file, int line) | 2213witness_assert(const struct lock_object *lock, int flags, const char *file, 2214 int line) |
2214{ 2215#ifdef INVARIANT_SUPPORT 2216 struct lock_instance *instance; 2217 struct lock_class *class; 2218 2219 if (lock->lo_witness == NULL || witness_watch < 1 || panicstr != NULL) 2220 return; 2221 class = LOCK_CLASS(lock); --- 604 unchanged lines hidden --- | 2215{ 2216#ifdef INVARIANT_SUPPORT 2217 struct lock_instance *instance; 2218 struct lock_class *class; 2219 2220 if (lock->lo_witness == NULL || witness_watch < 1 || panicstr != NULL) 2221 return; 2222 class = LOCK_CLASS(lock); --- 604 unchanged lines hidden --- |