Date: Tue, 11 Jan 2000 01:44:56 -0800 From: David Greenman <dg@root.com> To: Brian Fundakowski Feldman <green@FreeBSD.ORG> Cc: Stephen McKay <syssgm@detir.qld.gov.au>, freebsd-current@FreeBSD.ORG Subject: Re: Crash from ^T during heavy paging Message-ID: <200001110944.BAA20238@implode.root.com> In-Reply-To: Your message of "Tue, 11 Jan 2000 03:34:43 EST." <Pine.BSF.4.10.10001110327150.39255-100000@green.dyndns.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>On Mon, 10 Jan 2000, Stephen McKay wrote: > >> The problem is that calcru() thinks that P_INMEM means that the proc >> structure is fully and accurately populated. But P_INMEM is one of the >> first flags set. >> >> So, calcru() and possibly some other places, are looking at a struct proc >> before it's all there. What's the "proper" way to do it? > >It should really be one of the _last_ flags set, if it's to mean anything. >I don't know how to explain the prevalance of race conditions in the old >code, except to say it probably has to do with not planning ahead. >Certainly it's not acceptable to create new race conditions now (even if >it can happen by accident). > >So, here's something to defer P_INMEM til the end, when the process is >really "ready": > >--- sys/kern/kern_fork.c Tue Dec 7 22:11:35 1999 >+++ /tmp/kern_fork.c Tue Jan 11 03:32:44 2000 >@@ -351,7 +351,7 @@ > * Increase reference counts on shared objects. > * The p_stats and p_sigacts substructs are set in vm_fork. > */ >- p2->p_flag = P_INMEM; >+ p2->p_flag = 0; > if (p1->p_flag & P_PROFIL) > startprofclock(p2); > MALLOC(p2->p_cred, struct pcred *, sizeof(struct pcred), >@@ -499,6 +499,7 @@ > microtime(&(p2->p_stats->p_start)); > p2->p_acflag = AFORK; > (void) splhigh(); >+ p2->p_flag |= P_INMEM; > p2->p_stat = SRUN; > setrunqueue(p2); > (void) spl0(); It shouldn't be necessary to set the flag inside of splhigh. If you move it up a line I think you'll have a winner. -DG David Greenman Co-founder/Principal Architect, The FreeBSD Project - http://www.freebsd.org Creator of high-performance Internet servers - http://www.terasolutions.com Pave the road of life with opportunities. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001110944.BAA20238>