From 299bc7367df2e228f4fdb4890b11f99dde9861f0 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 1 Oct 2004 05:01:29 +0000 Subject: Avoid calling _PHOLD(p1) with p2's lock held, since _PHOLD() may block to swap in p1. Instead, call _PHOLD earlier, at a point where the only lock held happens to be p1's. --- sys/kern/kern_fork.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 714a1af63b59b..6e47e26bd6cac 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -533,8 +533,14 @@ again: * p_limit is copy-on-write. Bump its refcount. */ p2->p_limit = lim_hold(p1->p_limit); - PROC_UNLOCK(p1); + + /* + * We don't need to prevent the parent from being swapped out just yet, + * but this is a convenient point to block to swap it in if needed. + */ PROC_UNLOCK(p2); + _PHOLD(p1); + PROC_UNLOCK(p1); /* Bump references to the text vnode (for procfs) */ if (p2->p_textvp) @@ -629,9 +635,8 @@ again: /* * This begins the section where we must prevent the parent - * from being swapped. + * from being swapped. We already got a hold on the parent earlier. */ - _PHOLD(p1); PROC_UNLOCK(p1); /* -- cgit v1.3