* Robert Lipe <[EMAIL PROTECTED]> [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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to