Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_witness.c
| Show First 20 Lines • Show All 1,509 Lines • ▼ Show 20 Lines | witness_lock(struct lock_object *lock, int flags, const char *file, int line) | ||||
| td = curthread; | td = curthread; | ||||
| /* Determine lock list for this lock. */ | /* Determine lock list for this lock. */ | ||||
| if (LOCK_CLASS(lock)->lc_flags & LC_SLEEPLOCK) | if (LOCK_CLASS(lock)->lc_flags & LC_SLEEPLOCK) | ||||
| lock_list = &td->td_sleeplocks; | lock_list = &td->td_sleeplocks; | ||||
| else | else | ||||
| lock_list = PCPU_PTR(spinlocks); | lock_list = PCPU_PTR(spinlocks); | ||||
| /* Update per-witness last file and line acquire. */ | |||||
| w->w_file = file; | |||||
| w->w_line = line; | |||||
| /* Check to see if we are recursing on a lock we already own. */ | /* Check to see if we are recursing on a lock we already own. */ | ||||
| instance = find_instance(*lock_list, lock); | instance = find_instance(*lock_list, lock); | ||||
| if (instance != NULL) { | if (instance != NULL) { | ||||
| instance->li_flags++; | instance->li_flags++; | ||||
| CTR4(KTR_WITNESS, "%s: pid %d recursed on %s r=%d", __func__, | CTR4(KTR_WITNESS, "%s: pid %d recursed on %s r=%d", __func__, | ||||
| td->td_proc->p_pid, lock->lo_name, | td->td_proc->p_pid, lock->lo_name, | ||||
| instance->li_flags & LI_RECURSEMASK); | instance->li_flags & LI_RECURSEMASK); | ||||
| instance->li_file = file; | |||||
| instance->li_line = line; | |||||
| return; | return; | ||||
| } | } | ||||
| /* Update per-witness last file and line acquire. */ | |||||
| w->w_file = file; | |||||
| w->w_line = line; | |||||
| /* Find the next open lock instance in the list and fill it. */ | /* Find the next open lock instance in the list and fill it. */ | ||||
markj: Presumably we should deduplicate these assignments and move them before the find_instance()… | |||||
| lle = *lock_list; | lle = *lock_list; | ||||
| if (lle == NULL || lle->ll_count == LOCK_NCHILDREN) { | if (lle == NULL || lle->ll_count == LOCK_NCHILDREN) { | ||||
| lle = witness_lock_list_get(); | lle = witness_lock_list_get(); | ||||
| if (lle == NULL) | if (lle == NULL) | ||||
| return; | return; | ||||
| lle->ll_next = *lock_list; | lle->ll_next = *lock_list; | ||||
| CTR3(KTR_WITNESS, "%s: pid %d added lle %p", __func__, | CTR3(KTR_WITNESS, "%s: pid %d added lle %p", __func__, | ||||
| td->td_proc->p_pid, lle); | td->td_proc->p_pid, lle); | ||||
| ▲ Show 20 Lines • Show All 1,618 Lines • Show Last 20 Lines | |||||
Presumably we should deduplicate these assignments and move them before the find_instance() call?