: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
<[EMAIL PROTECTED]>
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message