Subject: Re: Speeding up fork/wait path
To: Frank van der Linden <fvdl@NetBSD.org>
From: Jaromir Dolecek <jdolecek@NetBSD.org>
List: tech-kern
Date: 10/29/2003 13:36:16
Frank van der Linden wrote:
> On Tue, Oct 28, 2003 at 12:11:13AM +0100, Manuel Bouyer wrote:
> > You could then have the reaper run as a background low-priority task.
> > It wouldn't need to be waked up at each process exit(), and could
> > batch the clean ups, reducing the number of context switches on a
> > loaded system.
>
> Yes, but that might give you the same problem as with the ffs syncer,
> i.e. possibly running into resource shortages if things fork/exit
> too quickly. Then you have to add hacks to kick the reaper into
> action, etc, etc.
Actually, it seems only the uarea needs to be freed from another
process context, at least on i386.
Reaper does this in case of last LWP + process exit on i386+amd64:
1. cpu_wait(), which in turn calls tss_free() - AFAICS this can be
called as the last potentially blocking operation within
the exiting process context, since the task switch info
won't be needed anymore after that
2. uvm_lwp_exit(), which frees uarea - must be called outside of the
context of exiting lwp/process, can sometimes block
3. lwp struct decommission - can be done from idle context
(e.g. in lwp_exit2()), doesn't block
4. process vmspace decommission - can be done from context
of the exiting thread
So without any significant changes, 1) & 4) can be done in
sys_exit(). 2) needs to be done before 3), so these would need
to be done by reaper still.
It would be possible to change uvm_uarea_free() to only
queue the 'freed' uareas in list, and have a background thread
free excessive uareas later. In this case, 2) won't block
anymore and can be run from idle context together with 3),
and reaper is no longer needed.
Jaromir
> - Frank
>
> --
> Frank van der Linden fvdl@netbsd.org
> ===============================================================================
> NetBSD. Free, Unix-like OS. > 45 different platforms. http://www.netbsd.org/
>
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.cz/
-=- We should be mindful of the potential goal, but as the tantric -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow. Do not let this distract you.'' -=-