Subject: Re: kernel mem
To: David Ferlier <>
From: Jaromir Dolecek <>
List: tech-kern
Date: 01/09/2003 23:13:08
Normally you use malloc(9) or pool(9) routines. Of course, disadvantage
of malloc(9) is that it allocates memory from interrupt-safe kernel
memory pool, which has certain fixed upper size.

You don't need to play directly with vm_space structures when
you use uvm_km_zalloc(). The returned vaddr_t can be directly
used for your data within kernel. If the memory is accessed
from process context always, you might consider using
uvm_km_valloc{_wait}(), which IIRC doesn't wire the memory
and demand-fills the virtual address range with physical pages.

Hopefuly this helps a little,


David Ferlier wrote:
> Hi,
> I am writing a piece of code (a filesystem), and i need to alloc kernel memory of
> a dynamic size for bitmap cache stuff.
> For the moment, i alloc'ed all that with uvm_km_zalloc, and then i read the
> vm_space structure, and do a loop over all the vm_map_entry structures it contains.
> I didn't test the code, but i'd like to know which of the uvm api or malloc(9) api (with
> a special type specific to the filesystem) to choose (before going further)
> Thanks in advance.
> -- 
> David Ferlier	-     || 
>	- Of Course It Runs NetBSD

Jaromir Dolecek <>  
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-