From owner-freebsd-hackers Mon Jan 22 12: 9:31 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mass.dis.org (mass.dis.org [216.240.45.41]) by hub.freebsd.org (Postfix) with ESMTP id D4DD037B6A6 for ; Mon, 22 Jan 2001 12:09:14 -0800 (PST) Received: from mass.dis.org (localhost [127.0.0.1]) by mass.dis.org (8.11.1/8.11.1) with ESMTP id f0MKOU001092; Mon, 22 Jan 2001 12:24:30 -0800 (PST) (envelope-from msmith@mass.dis.org) Message-Id: <200101222024.f0MKOU001092@mass.dis.org> X-Mailer: exmh version 2.1.1 10/15/1999 To: Robert Lipe Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: contigmalloc, M_WAITOK, & leaks. In-reply-to: Your message of "Mon, 22 Jan 2001 11:06:42 CST." <20010122110642.B10504@rjlhome.sco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 22 Jan 2001 12:24:30 -0800 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I'm calling contigmalloc() with M_WAITOK. For every contigmalloc, I > have a corresponding contigfree(). But after a few thousand cycles, > contigmalloc() starts returning NULL. It self-destructs in about 3 > minutes. I see the same behaviour with M_NOWAIT. As an aside, WAITOK's > should never return NULL, right? They should be put to sleep and > awakened when the resource is available. No, contigmalloc will return NULL if physical memory space is fragmented to the point where it can't honour your request. You should avoid calling contigmalloc at any time other than when setting up your driver; there is no support in the kernel for defragmenting physical address space, so over time you'll run into the problem you're seeing. Allocate your space up front, and then leave it alone. Also, you should probably be using bus_dmamem_alloc() since the only real use for contiguous memory is for DMA purposes, and you'll be better served by allocating DMA'able buffers matching your device's characteristics than by assuming that you can DMA to/from all physical memory. -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message