Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2014 21:24:37 -0800
From:      Rui Paulo <rpaulo@me.com>
To:        Mateusz Guzik <mjg@freebsd.org>
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:  <F0E05A56-5550-4B44-89BD-7B4055499E4A@me.com>
In-Reply-To: <201411060812.sA68CZ2w007383@svn.freebsd.org>
References:  <201411060812.sA68CZ2w007383@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Nov 6, 2014, at 00:12, Mateusz Guzik <mjg@freebsd.org> wrote:
>=20
> Author: mjg
> Date: Thu Nov  6 08:12:34 2014
> New Revision: 274167
> URL: https://svnweb.freebsd.org/changeset/base/274167
>=20
> Log:
>  Add sysctl kern.proc.cwd
>=20
>  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.
>=20
>  Submitted by:	Tiwei Bie <btw mail.ustc.edu.cn> (slightly =
modified)
>  X-Additional:	JuniorJobs project
>=20
> Modified:
>  head/sys/kern/kern_descrip.c
>  head/sys/sys/sysctl.h
>  head/sys/sys/user.h
>=20
> Modified: head/sys/kern/kern_descrip.c
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- 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");
>=20
> +/*
> + * 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






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F0E05A56-5550-4B44-89BD-7B4055499E4A>