From owner-p4-projects@FreeBSD.ORG Thu Dec 29 20:06:17 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EC6B016A422; Thu, 29 Dec 2005 20:06:16 +0000 (GMT) X-Original-To: perforce@freebsd.org 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 BE45D16A41F for ; Thu, 29 Dec 2005 20:06:16 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA17643D70 for ; Thu, 29 Dec 2005 20:06:00 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jBTK5xv2073611 for ; Thu, 29 Dec 2005 20:05:59 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jBTK5xIf073608 for perforce@freebsd.org; Thu, 29 Dec 2005 20:05:59 GMT (envelope-from jhb@freebsd.org) Date: Thu, 29 Dec 2005 20:05:59 GMT Message-Id: <200512292005.jBTK5xIf073608@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 88898 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2005 20:06:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=88898 Change 88898 by jhb@jhb_slimer on 2005/12/29 20:05:30 You can't call printf while holding the witness mutex or you can trigger a deadlock (which I've reproduced several times today ;-P) with the spin locks used in console drivers. Fix the one printf I recently added which had this bug. Affected files ... .. //depot/projects/smpng/sys/kern/subr_witness.c#145 edit Differences ... ==== //depot/projects/smpng/sys/kern/subr_witness.c#145 (text+ko) ==== @@ -1409,18 +1409,8 @@ return (w); } } - /* - * We issue a warning for any spin locks not defined in the static - * order list as a way to discourage their use (folks should really - * be using non-spin mutexes most of the time). However, several - * 3rd part device drivers use spin locks because that is all they - * have available on Windows and Linux and they think that normal - * mutexes are insufficient. - */ - if ((lock_class->lc_flags & LC_SPINLOCK) && witness_spin_warn) - printf("WITNESS: spin lock %s not in order list", description); if ((w = witness_get()) == NULL) - return (NULL); + goto out; w->w_name = description; w->w_class = lock_class; w->w_refcount = 1; @@ -1437,6 +1427,17 @@ lock_class->lc_name); } mtx_unlock_spin(&w_mtx); +out: + /* + * We issue a warning for any spin locks not defined in the static + * order list as a way to discourage their use (folks should really + * be using non-spin mutexes most of the time). However, several + * 3rd part device drivers use spin locks because that is all they + * have available on Windows and Linux and they think that normal + * mutexes are insufficient. + */ + if ((lock_class->lc_flags & LC_SPINLOCK) && witness_spin_warn) + printf("WITNESS: spin lock %s not in order list", description); return (w); } @@ -1988,7 +1989,7 @@ FOREACH_THREAD_IN_PROC(p, td) { if (!witness_thread_has_locks(td)) continue; - printf("Process %d (%s) thread %p (%d)\n", p->p_pid, + db_printf("Process %d (%s) thread %p (%d)\n", p->p_pid, p->p_comm, td, td->td_tid); witness_list(td); }