From owner-cvs-src-old@FreeBSD.ORG Mon Jun 13 21:21:27 2011 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FF7D106566B for ; Mon, 13 Jun 2011 21:21:27 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7E6F08FC19 for ; Mon, 13 Jun 2011 21:21:27 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id p5DLLR3x035399 for ; Mon, 13 Jun 2011 21:21:27 GMT (envelope-from gibbs@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id p5DLLRNw035398 for cvs-src-old@freebsd.org; Mon, 13 Jun 2011 21:21:27 GMT (envelope-from gibbs@repoman.freebsd.org) Message-Id: <201106132121.p5DLLRNw035398@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to gibbs@repoman.freebsd.org using -f From: "Justin T. Gibbs" Date: Mon, 13 Jun 2011 21:21:02 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/kern subr_devstat.c X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2011 21:21:27 -0000 gibbs 2011-06-13 21:21:02 UTC FreeBSD src repository Modified files: sys/kern subr_devstat.c Log: SVN rev 223061 on 2011-06-13 21:21:02Z by gibbs Fix a couple of race conditions in devstat(9) initialization. In devstat_new_entry(), there is no need to initialize the queue and the mutex in this function. There are ways to do static initialization on both, so use STAILQ_HEAD_INITIALIZER and MTX_SYSINIT to initialize the queue and the mutex. In devstat_alloc(), use an atomic test and set routine to guard making our entry in /dev. Using just a plain static variable creates a race condition on multiprocessor machines. If you attempt to create a second entry in devfs, the kernel will panic. Submitted by: kdm Reviewed by: gibbs Sponsored by: Spectra Logic Corporation MFC after: 1 week. Revision Changes Path 1.57 +3 -9 src/sys/kern/subr_devstat.c