Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Apr 2000 11:23:32 -0700 (PDT)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Anatoly Vorobey <mellon@pobox.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: memory in the kernel
Message-ID:  <200004161823.LAA87432@apollo.backplane.com>
References:   <20000416123037.A24869@happy.checkpoint.com>

next in thread | previous in thread | raw e-mail | index | archive | help
:I have to malloc a lot of memory in the kernel, hence a few
:questions:
:
:1. The data must be absolutely present at all times, no page
:faults or locking mechanisms, etc. Does that mean
:I should use kmem_alloc_wired() or am I misunderstanding its purpose?
:Does it make sense to alloc less than a pageful or is the rest simply
:going to be wasted?
:
:2. Unfortunately, I need to realloc a lot as data is dynamic and I
:don't know sizes beforehand. How do I do that? Do I malloc a new
:region, copy manually and release the old one?
:
:Thanks a lot in advance,
:Anatoly.
:
:-- 
:Anatoly Vorobey,

    At the moment all kernel memory is wired, so just use the kernel
    malloc() function.  Create your own malloc area (see other kernel
    source modules on how to do that, it's trivial).

    There is no kernel realloc().  Even if there were using realloc or
    a malloc-copy-free-old scheme can lead to severe fragmentation if you
    aren't careful.  If you can possibly avoid it, try to figure out the
    size of your structures before hand or even move to using a linked list
    rather then an array.  Otherwise the only way to do a realloc-like
    thing is to malloc the larger object, copy the old data, and then free
    the original object.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



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?200004161823.LAA87432>