Subject: Re: keeping the process start time in core at all times...
To: Chuck Silvers <chuq@chuq.com>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 12/02/2002 10:32:06
> this is because even though no uarea pages are paged out,
> some processes are "swapped out".  the latter just means that
> the uarea is unwired, so accessing it requires using (eg.) kcopy().
> 
> personally, I'd think it would be fine if the sysctl doodad that
> ps uses would just kcopy() out whatever uarea info it wants when
> P_INMEM is clear.

It struck me that using kcopy() would allow ps to sleep, this
would allow the process being looked at exit and invalidate
the LIST_NEXT(p, p_list) used to scan the process table.

I then looked at the code - always a bad move :-)

sysclt_doeproc() has the following structure:

    proclist_lock_read();

    for (p = LIST_FIRST(pd->pd_list); p != NULL; p = LIST_NEXT(p, p_list)) {
	    ...
	    error = copyout(&kproc2, dp2, ... )
	    ...
    }
    proclist_unlock_read();

This means it can sleep with the proclist read locked.

This is seriously bad news, and will wedge the system under
suitable conditions (running while (fork()) exit(0); might do it).

It needs to use a different scheme to ennumerate the processes,
or at least a different locking scheme.

(Oh yes: my pid allocater would allow such an ennumerater to be
easily written.... pfindnext(pid) would be trivial)

	David

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