From owner-svn-src-all@FreeBSD.ORG Sun Jan 4 22:08:51 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7EDB4127; Sun, 4 Jan 2015 22:08:51 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 095C629E0; Sun, 4 Jan 2015 22:08:50 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.9/8.14.9) with ESMTP id t04M8mdS076694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 5 Jan 2015 01:08:48 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.9/8.14.9/Submit) id t04M8mlX076693; Mon, 5 Jan 2015 01:08:48 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 5 Jan 2015 01:08:48 +0300 From: Gleb Smirnoff To: Hans Petter Selasky Subject: Re: svn commit: r276626 - head/sys/kern Message-ID: <20150104220848.GU15484@FreeBSD.org> References: <201501031721.t03HLKHp060964@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201501031721.t03HLKHp060964@svn.freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, avg@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jan 2015 22:08:51 -0000 Hi! On Sat, Jan 03, 2015 at 05:21:20PM +0000, Hans Petter Selasky wrote: H> Author: hselasky H> Date: Sat Jan 3 17:21:19 2015 H> New Revision: 276626 H> URL: https://svnweb.freebsd.org/changeset/base/276626 H> H> Log: H> Rework r276532 a bit. Always avoid recursing into the console drivers H> clients, hence they might not handle it very well. This change allows H> debugging mutex problems with kernel console drivers when H> "debug.witness.skipspin=0" is set in the boot environment. H> H> MFC after: 1 week I'd ask Andriy avg@ to review r276532 and this change. AFAIR, he attacked this problem in 2011/2012 and it appeared much more complex than just adding MTX_RECURSE flag. H> Modified: H> head/sys/kern/kern_cons.c H> H> Modified: head/sys/kern/kern_cons.c H> ============================================================================== H> --- head/sys/kern/kern_cons.c Sat Jan 3 16:48:08 2015 (r276625) H> +++ head/sys/kern/kern_cons.c Sat Jan 3 17:21:19 2015 (r276626) H> @@ -512,6 +512,13 @@ cnputs(char *p) H> int unlock_reqd = 0; H> H> if (use_cnputs_mtx) { H> + /* H> + * NOTE: Debug prints and/or witness printouts in H> + * console driver clients can cause the "cnputs_mtx" H> + * mutex to recurse. Simply return if that happens. H> + */ H> + if (mtx_owned(&cnputs_mtx)) H> + return; H> mtx_lock_spin(&cnputs_mtx); H> unlock_reqd = 1; H> } H> @@ -601,13 +608,7 @@ static void H> cn_drvinit(void *unused) H> { H> H> - /* H> - * NOTE: Debug prints and/or witness printouts in console H> - * driver clients can cause the "cnputs_mtx" mutex to H> - * recurse. Make sure the "MTX_RECURSE" flags is set! H> - */ H> - mtx_init(&cnputs_mtx, "cnputs_mtx", NULL, MTX_SPIN | H> - MTX_NOWITNESS | MTX_RECURSE); H> + mtx_init(&cnputs_mtx, "cnputs_mtx", NULL, MTX_SPIN | MTX_NOWITNESS); H> use_cnputs_mtx = 1; H> } H> H> -- Totus tuus, Glebius.