From owner-p4-projects@FreeBSD.ORG Mon Oct 24 15:49:53 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 33E2916A421; Mon, 24 Oct 2005 15:49:53 +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 0A20D16A41F for ; Mon, 24 Oct 2005 15:49:53 +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 5C10643D5D for ; Mon, 24 Oct 2005 15:49:52 +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 j9OFnqEv016591 for ; Mon, 24 Oct 2005 15:49:52 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9OFnqGq016588 for perforce@freebsd.org; Mon, 24 Oct 2005 15:49:52 GMT (envelope-from jhb@freebsd.org) Date: Mon, 24 Oct 2005 15:49:52 GMT Message-Id: <200510241549.j9OFnqGq016588@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 85783 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: Mon, 24 Oct 2005 15:49:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=85783 Change 85783 by jhb@jhb_slimer on 2005/10/24 15:49:43 Don't panic if a spin lock is added that is not in the static order list. Just warn about it instead. Affected files ... .. //depot/projects/smpng/sys/kern/subr_witness.c#140 edit Differences ... ==== //depot/projects/smpng/sys/kern/subr_witness.c#140 (text+ko) ==== @@ -450,6 +450,12 @@ static int witness_cold = 1; /* + * This global is set to 1 once the static lock orders have been enrolled + * so that a warning can be issued for any spin locks enrolled later. + */ +static int witness_spin_warn = 0; + +/* * Global variables for book keeping. */ static int lock_cur_cnt; @@ -500,6 +506,7 @@ w = w1; } } + witness_spin_warn = 1; /* Iterate through all locks and add them to witness. */ mtx_lock(&all_mtx); @@ -513,7 +520,7 @@ mtx_unlock(&all_mtx); /* Mark the witness code as being ready for use. */ - atomic_store_rel_int(&witness_cold, 0); + witness_cold = 0; mtx_lock(&Giant); } @@ -1403,13 +1410,15 @@ } } /* - * This isn't quite right, as witness_cold is still 0 while we - * enroll all the locks initialized before witness_initialize(). + * 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_cold) { - mtx_unlock_spin(&w_mtx); - panic("spin lock %s not in order list", description); - } + 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); w->w_name = description;