Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jan 2001 10:05:24 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Robert Lipe <robertlipe@usa.net>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: contigmalloc, M_WAITOK, & leaks.
Message-ID:  <20010122100524.D7240@fw.wintelcom.net>
In-Reply-To: <20010122110642.B10504@rjlhome.sco.com>; from robertlipe@usa.net on Mon, Jan 22, 2001 at 11:06:42AM -0600
References:  <20010122110642.B10504@rjlhome.sco.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Robert Lipe <robertlipe@usa.net> [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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010122100524.D7240>