From owner-p4-projects Wed Apr 17 12:40:44 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4D2F237B400; Wed, 17 Apr 2002 12:40:34 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 0D6B937B416; Wed, 17 Apr 2002 12:40:32 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020417194008.SXNU1901.rwcrmhc52.attbi.com@InterJet.elischer.org>; Wed, 17 Apr 2002 19:40:08 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id MAA98088; Wed, 17 Apr 2002 12:27:49 -0700 (PDT) Date: Wed, 17 Apr 2002 12:27:47 -0700 (PDT) From: Julian Elischer To: John Baldwin Cc: Perforce Change Reviews Subject: Re: PERFORCE change 9921 for review In-Reply-To: <200204171801.g3HI1Id36075@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 On Wed, 17 Apr 2002, John Baldwin wrote: > http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9921 > > Change 9921 by jhb@jhb_laptop on 2002/04/17 11:00:44 > > Only malloc newprocsig if we need it. To make this nicer we need > a procsig_alloc/hold/free(drop?)/dup/shared. At some point I would > like a standard naming scheme for all our refcounted objects as > above. Note that if _alloc() sets the refcount appropriately, then > it won't need to use separate drop/free routines. I also would > like for us to use common names for all these refcount operations. Very true.. In netgraph I use: {obj}_ref() (add a reference) {obj}_unref() (decrement and maybe free) {obj}_new() (returns with one reference preallocated for the caller to use.) > > Affected files ... > > ... //depot/projects/smpng/sys/kern/kern_exec.c#34 edit > > Differences ... > > ==== //depot/projects/smpng/sys/kern/kern_exec.c#34 (text+ko) ==== > > @@ -134,7 +134,7 @@ > struct vattr attr; > int (*img_first)(struct image_params *); > struct pargs *oldargs, *newargs = NULL; > - struct procsig *newprocsig = NULL; > + struct procsig *oldprocsig, *newprocsig; > struct vnode *tracevp = NULL, *textvp = NULL; > > imgp = &image_params; > @@ -299,8 +299,6 @@ > /* > * Malloc things before we need locks. > */ > - MALLOC(newprocsig, struct procsig *, sizeof(struct procsig), > - M_SUBPROC, M_WAITOK); > newcred = crget(); > i = imgp->endargs - imgp->stringbase; > if (ps_arg_cache_limit >= i + sizeof(struct pargs)) > @@ -318,10 +316,15 @@ > PROC_LOCK(p); > mp_fixme("procsig needs a lock"); > if (p->p_procsig->ps_refcnt > 1) { > - bcopy(p->p_procsig, newprocsig, sizeof(*newprocsig)); > - p->p_procsig->ps_refcnt--; > + oldprocsig = p->p_procsig; > + PROC_UNLOCK(p); > + MALLOC(newprocsig, struct procsig *, sizeof(struct procsig), > + M_SUBPROC, M_WAITOK); > + bcopy(oldprocsig, newprocsig, sizeof(*newprocsig)); > + newprocsig->ps_refcnt = 1; > + oldprocsig->ps_refcnt--; > + PROC_LOCK(p); > p->p_procsig = newprocsig; > - p->p_procsig->ps_refcnt = 1; > if (p->p_sigacts == &p->p_uarea->u_sigacts) > panic("shared procsig but private sigacts?"); > > @@ -458,8 +461,6 @@ > /* > * Free any resources malloc'd earlier that we didn't use. > */ > - if (newprocsig != NULL) > - FREE(newprocsig, M_SUBPROC); > if (newcred == NULL) > crfree(oldcred); > else > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message