From owner-freebsd-hackers Mon Jan 22 10: 5:49 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 8442E37B400 for ; Mon, 22 Jan 2001 10:05:26 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f0MI5Pd24288; Mon, 22 Jan 2001 10:05:25 -0800 (PST) Date: Mon, 22 Jan 2001 10:05:24 -0800 From: Alfred Perlstein To: Robert Lipe Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: contigmalloc, M_WAITOK, & leaks. Message-ID: <20010122100524.D7240@fw.wintelcom.net> References: <20010122110642.B10504@rjlhome.sco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010122110642.B10504@rjlhome.sco.com>; from robertlipe@usa.net on Mon, Jan 22, 2001 at 11:06:42AM -0600 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Robert Lipe [010122 09:04] wrote: > Hi, Gang. > > I know that anytime a message starts with a subject like this, the > first reaction is to think that I've hosed the heap or am not freeing > something. While it's possible, I really don't think I have. (I also > know that everyone thinks that. :-) > > I'm on FreeBSD 4.1.1. I've not seen any flagrantly smoking guns since > then in vm_page.c, although version 1.154 might be... > > 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. Making heavy use of contigmalloc is a bad idea, if you really need this contig allocations then allocate a fair number of them early and keep using them. Memory get's fragmented, there's not much you can do about it. I doubt that contigmalloc respects the WAITOK flag, there's a good chance that kernel memory has become so fragmented that your chances of successfully completing the contigmalloc are near zero, it's much better to return a temporary resource failure than block a kernel thread forever. This issue has come up before, and most everyone was able to either use a workaround (calling VTOPHYS? on each page) or pre-allocating the contig space and reuseing it instead of allocating and freeing it over and over. best of luck, -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message