From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 21 20:33:52 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 433F816A41F; Fri, 21 Oct 2005 20:33:52 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7950243D5C; Fri, 21 Oct 2005 20:33:49 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.13.3/8.13.1) with ESMTP id j9LKW9EL026815; Fri, 21 Oct 2005 16:32:09 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.13.3/8.13.1/Submit) id j9LKW7g3026814; Fri, 21 Oct 2005 16:32:07 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Fri, 21 Oct 2005 16:32:07 -0400 From: David Schultz To: John Baldwin Message-ID: <20051021203207.GA26616@VARK.MIT.EDU> Mail-Followup-To: John Baldwin , freebsd-hackers@FreeBSD.ORG, nocool , freebsd-current , delphij References: <20051021131329.A16FC126E@smtp.263.net> <200510211239.35190.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii:iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200510211239.35190.jhb@freebsd.org> Cc: freebsd-hackers@FreeBSD.ORG, delphij , 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 20:33:52 -0000 On Fri, Oct 21, 2005, John Baldwin wrote: > On Friday 21 October 2005 09:13 am, nocool wrote: > > freebsd-hackersļ¼Œhello > > > > 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 = 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, will > > there be memory leakage? > > Heh, das@ forgot to call pstats_free() when he did the changes. The reason > is probably because proc_fini() doesn't do anything useful because we never > recycle proc structs. We should probably at least add the operations there > though for documentation purposes. Something like this would work I think: I didn't put in the call because we never free proc structures, but documenting what should happen if we ever do free them is a good idea. There's a fair amount of other cleanup that needs to happen as well, which you can probably find in the CVS history. (IIRC, I'm guilty of removing the code at a time when more things depended upon struct proc being type safe. Are there any remaining reasons why we can't free struct procs at this point?) By the way, there's no reason why we can't fold struct pstats into struct proc so we don't have to allocate and free it at all. It's never shared, so the extra level of indirection just adds overhead. The main reason I didn't make this change earlier was to maintain binary compatibility when I backported my U-area changes to -STABLE.