Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Mar 2011 11:25:47 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@freebsd.org, Edward Tomasz Napierala <trasz@freebsd.org>, svn-src-all@freebsd.org, src-committers@freebsd.org, Julian Elischer <julian@freebsd.org>
Subject:   Re: svn commit: r219727 - head/sys/vm
Message-ID:  <201103231125.48082.jhb@freebsd.org>
In-Reply-To: <20110323143434.GZ78089@deviant.kiev.zoral.com.ua>
References:  <201103180647.p2I6lNCB051745@svn.freebsd.org> <201103230945.37726.jhb@freebsd.org> <20110323143434.GZ78089@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, March 23, 2011 10:34:34 am Kostik Belousov wrote:
> On Wed, Mar 23, 2011 at 09:45:37AM -0400, John Baldwin wrote:
> > On Friday, March 18, 2011 4:40:34 am Julian Elischer wrote:
> > > On 3/17/11 11:47 PM, Edward Tomasz Napierala wrote:
> > > > Author: trasz
> > > > Date: Fri Mar 18 06:47:23 2011
> > > > New Revision: 219727
> > > > URL: http://svn.freebsd.org/changeset/base/219727
> > > >
> > > > Log:
> > > >    In vm_daemon(), when iterating over all processes in the system, 
skip those
> > > >    which are not yet fully initialized (i.e. ones with p_state == 
PRS_NEW).
> > > >    Without it, we could panic in _thread_lock_flags().
> > > >
> > > >    Note that there may be other instances of FOREACH_PROC_IN_SYSTEM() 
that
> > > >    require similar fix.
> > > 
> > > In the past each process was only put on the process list after it was 
> > > fully set up.
> > > Did someone change that recently?  that would be "A Bad Thing" (TM).
> > 
> > Err, no, that has never been true.  The reason it has to go on the list
> > immediately is to reserve the PID against concurrent fork()s.
> > 
> > Hmm, the locking of prs_state is a bit busted it seems.  Both the 
PROC_LOCK()
> > and PROC_SLOCK() are supposed to be held when it is written to, but
> > PROC_LOCK() is missing in fork1() when moving the state to PRS_NORMAL.
> > 
> > Also, this commit should check against PRS_NORMAL after acquiring the proc
> > lock, not before.
> In the case of this commit, it does not matter much, I think. The reason
> is that all the check want is to make sure that there is at least one
> fully initialized thread linked into the process.

It already checks other things under the proc lock, so it costs nothing to be
completely correct in this case.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103231125.48082.jhb>