]> xenbits.xensource.com Git - freebsd.git/commitdiff
proc: clear pid bitmap entry after dropping proctree lock
authormjg <mjg@FreeBSD.org>
Mon, 2 Sep 2019 12:46:43 +0000 (12:46 +0000)
committermjg <mjg@FreeBSD.org>
Mon, 2 Sep 2019 12:46:43 +0000 (12:46 +0000)
There is no correctness change here, but the procid lock is contended in
the fork path and taking it while holding proctree avoidably extends its
hold time.

Note that there are other ids which can end up getting cleared with the
lock.

Sponsored by: The FreeBSD Foundation

sys/kern/kern_exit.c

index dd227391e5e458ee30f8cb28ba1a119c2e54b87c..d0577303b95b4ba3d8f379e215c741023ef28c78 100644 (file)
@@ -906,7 +906,6 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
        LIST_REMOVE(p, p_sibling);
        reaper_abandon_children(p, true);
        reaper_clear(p);
-       proc_id_clear(PROC_ID_PID, p->p_pid);
        PROC_LOCK(p);
        proc_clear_orphan(p);
        PROC_UNLOCK(p);
@@ -915,6 +914,8 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
                procdesc_reap(p);
        sx_xunlock(&proctree_lock);
 
+       proc_id_clear(PROC_ID_PID, p->p_pid);
+
        PROC_LOCK(p);
        knlist_detach(p->p_klist);
        p->p_klist = NULL;