From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 21 16:43:55 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8CF4C16A41F; Fri, 21 Oct 2005 16:43:55 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id E99A343D45; Fri, 21 Oct 2005 16:43:54 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from [10.50.41.234] (Not Verified[10.50.41.234]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Fri, 21 Oct 2005 12:54:38 -0400 From: John Baldwin To: freebsd-hackers@freebsd.org Date: Fri, 21 Oct 2005 12:39:33 -0400 User-Agent: KMail/1.8.2 References: <20051021131329.A16FC126E@smtp.263.net> In-Reply-To: <20051021131329.A16FC126E@smtp.263.net> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200510211239.35190.jhb@freebsd.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Cc: delphij , das , freebsd-current , nocool Subject: Re: where to release proc.p_stats X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2005 16:43:55 -0000 On Friday 21 October 2005 09:13 am, nocool wrote: > freebsd-hackers=EF=BC=8Chello > > Question about 5.4 kernel source code. > I have some question about strust proc's initialize. Kernel use proc_zone > to allocate proc items and initialize them with proc_init > (sys\kern\kern_proc.c) function. In this function, we can find the field > proc.p_stats is allocated with pstats_alloc(), as > > p->p_stats =3D pstats_alloc(); > > and pstats_alloc is realized as > > malloc(sizeof(struct pstats), M_SUBPROC, M_ZERO|M_WAITOK); > > But I can't find where this field is freed. If it will not be release, wi= ll > there be memory leakage? Heh, das@ forgot to call pstats_free() when he did the changes. The reason= =20 is probably because proc_fini() doesn't do anything useful because we never= =20 recycle proc structs. We should probably at least add the operations there= =20 though for documentation purposes. Something like this would work I think: Index: kern_proc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sys/kern/kern_proc.c,v retrieving revision 1.232 diff -u -r1.232 kern_proc.c =2D-- kern_proc.c 2 Oct 2005 23:27:56 -0000 1.232 +++ kern_proc.c 21 Oct 2005 16:38:45 -0000 @@ -197,7 +197,14 @@ proc_fini(void *mem, int size) { +#ifdef notnow + pstats_free(p->p_stats); + mtx_destroy(&p->p_mtx); + ksegrp_free(FIRST_KSEGRP_IN_PROC(p)); + thread_free(FIRST_THREAD_IN_PROC(p)); +#else panic("proc reclaimed"); +#endif } /* =2D-=20 John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =3D http://www.FreeBSD.org