Date: Mon, 22 Jan 2001 12:24:30 -0800 From: Mike Smith <msmith@freebsd.org> To: Robert Lipe <robertlipe@usa.net> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: contigmalloc, M_WAITOK, & leaks. Message-ID: <200101222024.f0MKOU001092@mass.dis.org> In-Reply-To: Your message of "Mon, 22 Jan 2001 11:06:42 CST." <20010122110642.B10504@rjlhome.sco.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101222024.f0MKOU001092>