From owner-p4-projects Tue Dec 10 10:42:32 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B1AB137B404; Tue, 10 Dec 2002 10:42:29 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4850637B401 for ; Tue, 10 Dec 2002 10:42:29 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 84B2343EA9 for ; Tue, 10 Dec 2002 10:42:28 -0800 (PST) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gBAIbfmV026168 for ; Tue, 10 Dec 2002 10:37:41 -0800 (PST) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gBAIbfqE026165 for perforce@freebsd.org; Tue, 10 Dec 2002 10:37:41 -0800 (PST) Date: Tue, 10 Dec 2002 10:37:41 -0800 (PST) Message-Id: <200212101837.gBAIbfqE026165@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 22140 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=22140 Change 22140 by jhb@jhb_laptop on 2002/12/10 10:37:10 Add some hokie code to witness so that if we panic from spinning too long on a spin lock, we try to use witness info to determine where the other CPU acquired the lock in question. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#55 edit .. //depot/projects/smpng/sys/kern/subr_witness.c#66 edit .. //depot/projects/smpng/sys/sys/lock.h#23 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#55 (text+ko) ==== @@ -681,12 +681,18 @@ if (i < 60000000) DELAY(1); #ifdef DDB - else if (!db_active) + else if (!db_active) { #else - else + else { #endif - panic("spin lock %s held by %p for > 5 seconds", + printf("spin lock %s held by %p for > 5 seconds\n", m->mtx_object.lo_name, (void *)m->mtx_lock); +#ifdef WITNESS + witness_display_spinlock(&m->mtx_object, + mtx_owner(m)); +#endif + panic("spin lock held too long"); + } #ifdef __i386__ ia32_pause(); #endif ==== //depot/projects/smpng/sys/kern/subr_witness.c#66 (text+ko) ==== @@ -1399,6 +1399,28 @@ } /* + * This is a bit risky at best. We have call this when we have timed out + * acquiring a spin lock and are assuming that the other CPU is stuck with + * this lock held. So, we go groveling around in the other CPU's per-cpu + * data to try and find the lock instance for this spin lock to see when it + * was last acquired. + */ +void +witness_display_spinlock(struct lock_object *lock, struct thread *owner) +{ + struct lock_instance *instance; + struct pcpu *pc; + + if (owner->td_critnest == 0 || owner->td_kse != NULL || + owner->td_kse->ke_oncpu == NOCPU) + return; + pc = pcpu_find(owner->td_kse->ke_oncpu); + instance = find_instance(pc->pc_spinlocks, lock); + if (instance != NULL) + witness_list_lock(instance); +} + +/* * Calling this on td != curthread is bad unless we are in ddb. */ static int ==== //depot/projects/smpng/sys/sys/lock.h#23 (text+ko) ==== @@ -208,6 +208,7 @@ int witness_warn(int, struct lock_object *, const char *, int, const char *, ...); void witness_assert(struct lock_object *, int, const char *, int); +void witness_display_spinlock(struct lock_object *, struct thread *); int witness_line(struct lock_object *); const char *witness_file(struct lock_object *); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message