From owner-p4-projects Wed Apr 10 12:16:46 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6E26637B41C; Wed, 10 Apr 2002 12:16:31 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6865037B400 for ; Wed, 10 Apr 2002 12:16:24 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3AJGOX68182 for perforce@freebsd.org; Wed, 10 Apr 2002 12:16:24 -0700 (PDT) (envelope-from jhb@freebsd.org) Date: Wed, 10 Apr 2002 12:16:24 -0700 (PDT) Message-Id: <200204101916.g3AJGOX68182@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 9529 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9529 Change 9529 by jhb@jhb_laptop on 2002/04/10 12:15:51 - First, fix a lock order reversal. pgrp comes before proc. - Second, limcopy() can block, so release locks around the limit stuff for now until the limit stuff is reworked. Also, this lets us not hold pgrpsess and pgrp locks quite so long. Affected files ... ... //depot/projects/smpng/sys/kern/kern_fork.c#36 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_fork.c#36 (text+ko) ==== @@ -465,10 +465,8 @@ (unsigned) RANGEOF(struct ksegrp, kg_startzero, kg_endzero)); mtx_init(&p2->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK); - PGRPSESS_XLOCK(); PROC_LOCK(p2); PROC_LOCK(p1); - PGRP_LOCK(p1->p_pgrp); bcopy(&p1->p_startcopy, &p2->p_startcopy, (unsigned) RANGEOF(struct proc, p_startcopy, p_endcopy)); @@ -556,6 +554,8 @@ if (p2->p_textvp) VREF(p2->p_textvp); p2->p_fd = fd; + PROC_UNLOCK(p1); + PROC_UNLOCK(p2); /* * If p_limit is still copy-on-write, bump refcnt, @@ -570,6 +570,11 @@ p2->p_limit->p_refcnt++; } + PGRPSESS_XLOCK(); + PGRP_LOCK(p1->p_pgrp); + PROC_LOCK(p2); + PROC_LOCK(p1); + /* * Preserve some more flags in subprocess. PS_PROFIL has already * been preserved. @@ -584,6 +589,7 @@ LIST_INSERT_AFTER(p1, p2, p_pglist); PGRP_UNLOCK(p1->p_pgrp); + PGRPSESS_XUNLOCK(); LIST_INIT(&p2->p_children); LIST_INIT(&td2->td_contested); /* XXXKSE only 1 thread? */ @@ -618,7 +624,6 @@ _PHOLD(p1); PROC_UNLOCK(p1); PROC_UNLOCK(p2); - PGRPSESS_XUNLOCK(); /* * Attach the new process to its parent. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message