Date: Fri, 21 Nov 2014 06:50:59 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Rui Paulo <rpaulo@me.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r274167 - in head/sys: kern sys Message-ID: <20141121055059.GB22273@dft-labs.eu> In-Reply-To: <F0E05A56-5550-4B44-89BD-7B4055499E4A@me.com> References: <201411060812.sA68CZ2w007383@svn.freebsd.org> <F0E05A56-5550-4B44-89BD-7B4055499E4A@me.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 20, 2014 at 09:24:37PM -0800, Rui Paulo wrote: > On Nov 6, 2014, at 00:12, Mateusz Guzik <mjg@freebsd.org> 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 <btw mail.ustc.edu.cn> (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 <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141121055059.GB22273>