From owner-svn-src-head@FreeBSD.ORG Fri Nov 21 05:51:05 2014 Return-Path: Delivered-To: svn-src-head@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 049C161E; Fri, 21 Nov 2014 05:51:05 +0000 (UTC) Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [IPv6:2a00:1450:400c:c00::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 87AC6914; Fri, 21 Nov 2014 05:51:04 +0000 (UTC) Received: by mail-wg0-f50.google.com with SMTP id k14so5590062wgh.9 for ; Thu, 20 Nov 2014 21:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=WvhZp56qGFIJrkpm4YJlM26Qco9ccH/f1OTU36Qp/GE=; b=GLSmP+l8FwuLzeKeKXYfW8lXU9qe5PDGP/vNF66smZ8EkFJBOxAuHajsoPR5i6vHoR r+4L2ZchVavIEJq3d6cfZ49PmeeVvT9+VBYeEKb76eIYZDHvx1e82GMDBYZL9Q+PfxNp 33g6vYWHkgGPzd/4yNrcrTQVvY6smib80+lNUPbZz8pd+gy/2unLZ8d12fMTuBILhLoy U6aghHh1ivNJESkQl8kTkj06G+cQYgbXw16eTzJ6MvzRPQjGzIkM6MNAksKiuRfwKhWN qDzwCkrpTdfXD8V6VTOsRYPYBQDlcZoVVDpAzy5vqY+bpfp6j5pRPAgACeoLsC2zZCAS Fo/A== X-Received: by 10.181.8.70 with SMTP id di6mr22493216wid.9.1416549063026; Thu, 20 Nov 2014 21:51:03 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id e7sm6496793wjx.31.2014.11.20.21.51.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 20 Nov 2014 21:51:02 -0800 (PST) Date: Fri, 21 Nov 2014 06:50:59 +0100 From: Mateusz Guzik To: Rui Paulo Subject: Re: svn commit: r274167 - in head/sys: kern sys Message-ID: <20141121055059.GB22273@dft-labs.eu> References: <201411060812.sA68CZ2w007383@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: Fri, 21 Nov 2014 05:51:05 -0000 On Thu, Nov 20, 2014 at 09:24:37PM -0800, Rui Paulo wrote: > On Nov 6, 2014, at 00:12, Mateusz Guzik wrote: > > > > Author: mjg > > Date: Thu Nov 6 08:12:34 2014 > > New Revision: 274167 > > URL: https://svnweb.freebsd.org/changeset/base/274167 > > > > Log: > > Add sysctl kern.proc.cwd > > > > It returns only current working directory of given process which saves a lot of > > overhead over kern.proc.filedesc if given proc has a lot of open fds. > > > > Submitted by: Tiwei Bie (slightly modified) > > X-Additional: JuniorJobs project > > > > Modified: > > head/sys/kern/kern_descrip.c > > head/sys/sys/sysctl.h > > head/sys/sys/user.h > > > > Modified: head/sys/kern/kern_descrip.c > > ============================================================================== > > --- head/sys/kern/kern_descrip.c Thu Nov 6 07:44:10 2014 (r274166) > > +++ head/sys/kern/kern_descrip.c Thu Nov 6 08:12:34 2014 (r274167) > > @@ -3406,6 +3406,73 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC > > CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_filedesc, > > "Process filedesc entries"); > > > > +/* > > + * Store a process current working directory information to sbuf. > > + * > > + * Takes a locked proc as argument, and returns with the proc unlocked. > > I never really liked this approach because it makes it harder to see the locking pattern. > > Why not call fdhold(p) in the sysctl handler, unlock the process, call kern_proc_cwd_out() with an additional fdp argument, and then call fddrop()? > This code just mimics what was done with kern_proc_filedesc_out, which happens to have semi-valid usecase when fdhold returns NULL. In general I agree and this scheme is going away. I have a patch in my backlog which "pins" the process (i.e. prevents exec and exit) for the duration of kern_proc_filedesc_out/whatever, so it will effectively mean such functions will no longer play with fdhold/fddrop. Interestingly enough this requires some changes in devfs and I didn't have the time to ensure they work properly. -- Mateusz Guzik