From owner-freebsd-hackers Mon Oct 15 23:29:39 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from alicia.nttmcl.com (alicia.nttmcl.com [216.69.69.10]) by hub.freebsd.org (Postfix) with ESMTP id 91B5837B408 for ; Mon, 15 Oct 2001 23:29:35 -0700 (PDT) Received: (from gene@localhost) by alicia.nttmcl.com (8.10.1/8.10.1) id f9G6TWS15698; Mon, 15 Oct 2001 23:29:32 -0700 (PDT) Date: Mon, 15 Oct 2001 23:29:32 -0700 From: "Eugene M. Kim" To: "Eugene M. Kim" Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: contigmalloc + contigfree = memory leak? Message-ID: <20011015232932.A15142@alicia.nttmcl.com> References: <20011016144217.A35188@the-7.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20011016144217.A35188@the-7.net>; from ab@astralblue.net on Tue, Oct 16, 2001 at 02:42:17PM +0900 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Oops, I'm sorry for the self-reply. Just found a highly helpful thread posted from 11th (`contigfree, free what?'), so please disregard my message. /me bonks his head against a wall that says `mea culpa' Thanks, Eugene On Tue, Oct 16, 2001 at 02:42:17PM +0900, Eugene M. Kim wrote: > > > Greetings, > > QUESTION: > Does contigfree() really free up memory allocated using contigmalloc()? > > BACKGROUND: > I've been trying to make up a kmod that allocates/deallocates memory in > a specific physical address range. Mike Smith suggested using busdma > functions to do the job, so I followed it. > > After allocating and deallocating memory several times, it seemed that > bus_dmamem_free() was not freeing the memory properly. I looked at > busdma_machdep.c where bus_dmamem_free() was defined, and found: > > void > bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) > { > /* > * dmamem does not need to be bounced, so the map should be > * NULL > */ > if (map != NULL) > panic("bus_dmamem_free: Invalid map freed\n"); > /* XXX There is no "contigfree" and "free" doesn't work */ > if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) > free(vaddr, M_DEVBUF); > } > > However, there *is* contigfree() and a related patch was applied on > -current around August, so I did the same thing (adding an else clause > to call contigfree(vaddr, dmat->maxsize, M_DEVBUF)). > > It didn't solve the memory leak problem either, so I'm stuck here... > > Could anyone shed a light on this? > > Regards, > Eugene > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message