svn commit: r274167 - in head/sys: kern sys

Rui Paulo rpaulo at me.com
Fri Nov 21 05:25:02 UTC 2014


On Nov 6, 2014, at 00:12, Mateusz Guzik <mjg at 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()?

--
Rui Paulo





More information about the svn-src-all mailing list