Subject: Re: uvm_vslock / uvm_vsunlock problems
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 07/13/2003 20:05:34
On Fri, Jul 11, 2003 at 04:54:58PM -0400, Stephan Uphoff wrote:
> 
> David Laight wrote:
> > sysctl kern.proc has the process table write lock held, so must not block.
> > 
> > It is possible to enumerate the process table without disabling pre-emption
> > (which is why sysctl for ps has to lock down the user memory).
> > You would (probably) want to block fork and exit in order to get a
> > consistent view [1].
> > [...]
> > [1] otherwise a process could 'hide' by calling 'if (fork() > 0) exit(0);'
> > in a loop.
> 
> 
> I like the enumeration approach.
> However I would dislike blocking fork and exit.
> Maybe we can enumerate by using a dummy proc object as
> a place holder in the allproc list.
> Enumerating the list backwards should prevent [1].
> Not exactly a snapshot of the process table - but should be good 
> enough.

After my (recentish) revamp of the pid-allocater, the traversal is
just a matter of looking at the each entry of pid_table[] in turn.
The only complication happens when expand_pid_table() is called.

The allocations are pseudo-random (not sequential) so you cant guatantee
to catch someone doing 'if (fork() > 0) exit(0);' unless you block
fork or exit for the duration of the sysctl call.

OTOH if it is enough that ps reports all the processes that were active
when it started, and are active when it finished the it is easy.

	David

-- 
David Laight: david@l8s.co.uk