On Mon, Feb 17, 2025 at 02:20:57PM +0100, Martin Pieuchot wrote:
> On 17/02/25(Mon) 03:16, Claudio Jeker wrote:
> > CVSROOT:    /cvs
> > Module name:        src
> > Changes by: clau...@cvs.openbsd.org 2025/02/17 03:16:05
> > 
> > Modified files:
> >     sys/kern       : kern_exit.c 
> > 
> > Log message:
> > Use ps_mtx to lock the child process that is being checked by dowait6.
> > 
> > The checks of the various ps_flags field is all but atomic so we need
> > to lock the process before doing all these checks. Only that way a
> > reliable result is seen. It also ensures that the child process did
> > finish the transition before signaling up to the parent.
> 
> Why not read `ps_flags' only once?

We could do that. Will it help, not sure. I fought enough with dowait6()
and just want to be sure to not trip over it all the time.
 
> Anyway I don't understand what is being protected here.  It is really
> hard to follow without documentation.  Can you tells us which fields
> you're serializing access with `ps_mtx' in sys/proc.h?
> 
> This should be like the manual rule.  Locking MUST BE documented.

The problem is that the atomic flags are not atomic with the process
state. So right now I prefer to use a mutex and make sure that there are
no concurrency issues. The wait process wants to inspect the current state
of a process and to do that it should hold the ps_mtx so that the state is
stable.
This is mainly for stop and continue signaling, exit is a different beast
but will also require this in the long run.

How do you want this documented?
-- 
:wq Claudio

Reply via email to