Date: Wed, 10 Apr 2002 12:16:24 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 9529 for review Message-ID: <200204101916.g3AJGOX68182@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204101916.g3AJGOX68182>