From owner-svn-src-all@FreeBSD.ORG Wed Apr 13 14:33:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D870106564A; Wed, 13 Apr 2011 14:33:52 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from gw01.mail.saunalahti.fi (gw01.mail.saunalahti.fi [195.197.172.115]) by mx1.freebsd.org (Postfix) with ESMTP id 4967A8FC19; Wed, 13 Apr 2011 14:33:51 +0000 (UTC) Received: from a91-153-123-205.elisa-laajakaista.fi (a91-153-123-205.elisa-laajakaista.fi [91.153.123.205]) by gw01.mail.saunalahti.fi (Postfix) with SMTP id D650D1515F1; Wed, 13 Apr 2011 17:33:45 +0300 (EEST) Date: Wed, 13 Apr 2011 17:33:45 +0300 From: Jaakko Heinonen To: Alexander Motin Message-ID: <20110413143345.GA1553@a91-153-123-205.elisa-laajakaista.fi> References: <201104081442.p38EgUhl083322@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201104081442.p38EgUhl083322@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220454 - in head: share/man/man4 sys/cam/ata sys/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 13 Apr 2011 14:33:52 -0000 On 2011-04-08, Alexander Motin wrote: > - Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching > on per-device basis. > --- head/sys/cam/ata/ata_da.c Fri Apr 8 14:39:41 2011 (r220453) > +++ head/sys/cam/ata/ata_da.c Fri Apr 8 14:42:29 2011 (r220454) > @@ -738,6 +773,10 @@ adaregister(struct cam_periph *periph, v > softc->quirks = ((struct ada_quirk_entry *)match)->quirks; > else > softc->quirks = ADA_Q_NONE; > + softc->write_cache = -1; > + snprintf(announce_buf, sizeof(announce_buf), > + "kern.cam.ada.%d.writa_cache", periph->unit_number); ^^^ Typo. > + TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); TUNABLE_INT_FETCH() uses getenv() which may sleep (due to M_WAITOK allocation). You will get a witness warning (see below) on a WITNESS enabled kernel because the sim mutex is held in adaregister(). The tunable must exist, otherwise getenv() doesn't allocate memory. cd(4) has the same problem for kern.cam.cd.%d.minimum_cmd_size tunable and da(4) for kern.cam.da.%d.minimum_cmd_size tunable. I am considering adding WITNESS_WARN() to getenv() to expose these bugs early. uma_zalloc_arg: zone "16" with the following non-sleepable locks held: exclusive sleep mutex ATA state lock (ATA state lock) r = 0 (0xc42e0174) locked @ /home/jaakko/src/head/sys/cam/cam_xpt.c:1991 KDB: stack backtrace: db_trace_self_wrapper(c0cccf87,c0cca676,192,0,0,...) at db_trace_self_wrapper+0x26 kdb_backtrace(7c7,0,ffffffff,c0f8d60c,d8cc8cfc,...) at kdb_backtrace+0x2a _witness_debugger(c0ccfeaa,d8cc8d10,4,1,0,...) at _witness_debugger+0x25 witness_warn(5,0,c0d0361e,c0c81bfe,c0cbef65,...) at witness_warn+0x1fe uma_zalloc_arg(c15b99c0,0,2,2,0,...) at uma_zalloc_arg+0x34 malloc(2,c0dd29f0,2,156,310000,...) at malloc+0x113 getenv(d8cc90b8,d8cc8ec4,a,d8cc8efc,d8cc90b8,...) at getenv+0xea getenv_quad(d8cc90b8,d8cc8ee0,d8cc8efc,d8cc8efc,d8cc9118,...) at getenv_quad+0x1a getenv_int(d8cc90b8,c456b044,c0c2a8fe,0,c048d560,...) at getenv_int+0x18 adaregister(c4219080,d8cc9694,d8cc9170,0,0,...) at adaregister+0x1ef -- Jaakko