From owner-svn-src-head@FreeBSD.ORG Thu Feb 26 21:45:12 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 67A5ECBB; Thu, 26 Feb 2015 21:45:12 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37467C09; Thu, 26 Feb 2015 21:45:12 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 88727B93B; Thu, 26 Feb 2015 16:45:10 -0500 (EST) From: John Baldwin To: Mateusz Guzik Subject: Re: svn commit: r278320 - in head: contrib/mdocml lib lib/libdevctl share/mk sys/dev/acpica sys/dev/pci sys/kern sys/sys usr.sbin usr.sbin/devctl Date: Thu, 26 Feb 2015 16:11:36 -0500 Message-ID: <3996015.K3fJrHix9v@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <20150226192833.GB3799@dft-labs.eu> References: <201502061609.t16G92rn091851@svn.freebsd.org> <6369280.lTKc42i0bJ@ralph.baldwin.cx> <20150226192833.GB3799@dft-labs.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 26 Feb 2015 16:45:10 -0500 (EST) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Feb 2015 21:45:12 -0000 On Thursday, February 26, 2015 08:28:33 PM Mateusz Guzik wrote: > On Thu, Feb 26, 2015 at 07:46:38AM -0500, John Baldwin wrote: > > On Thursday, February 26, 2015 12:40:06 AM Mateusz Guzik wrote: > > > On Fri, Feb 06, 2015 at 04:09:02PM +0000, John Baldwin wrote: > > > > Author: jhb > > > > Date: Fri Feb 6 16:09:01 2015 > > > > New Revision: 278320 > > > > URL: https://svnweb.freebsd.org/changeset/base/278320 > > > > > > > > Log: > > > > Add a new device control utility for new-bus devices called devctl. > > > > This > > > > allows the user to request administrative changes to individual > > > > devices > > > > > > [..] > > > > > > > +static int > > > > +devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, > > > > + struct thread *td) > > > > +{ > > > > + struct devreq *req; > > > > + device_t dev; > > > > + int error, old; > > > > + > > > > + /* Locate the device to control. */ > > > > + mtx_lock(&Giant); > > > > + req = (struct devreq *)data; > > > > > > [..] > > > > > > > + switch (cmd) { > > > > > > [..] > > > > > > > + case DEV_SET_DRIVER: { > > > > + devclass_t dc; > > > > + char driver[128]; > > > > + > > > > + error = copyinstr(req->dr_data, driver, sizeof(driver), NULL); > > > > > > [..] > > > > > > > + if (!driver_exists(dev->parent, driver)) { > > > > + error = ENOENT; > > > > + break; > > > > + } > > > > > > [..] > > > > > > > + } > > > > + mtx_unlock(&Giant); > > > > + return (error); > > > > +} > > > > > > I only skimmed thourgh this, will not a page fault drop + reacquire > > > Giant > > > lock? > > > > > > iow, would not it be better to copy prior to taking the lock? > > > > It won't make a difference. All the logic is done after the copy, so it > > is > > still atomic. > > Are devices guaranteed to be persistent? > > find_device does ref them in any way, so i would assume that the dev you > found is only stable as long as Giant lock is held. Ah, fair enough. Even when new-bus doesn't need Giant it would probably need this fix as well. -- John Baldwin