Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

memoryallocators(9) [netbsd man page]

MEMORYALLOCATORS(9)					   BSD Kernel Developer's Manual				       MEMORYALLOCATORS(9)

NAME
memoryallocators -- introduction to kernel memory allocators DESCRIPTION
The NetBSD kernel provides several memory allocators, each with different characteristics and purpose. This document summarizes the main differences between them. The Kmem Allocator The kmem allocator is modelled after an interface of similar name implemented in Solaris. This is main general purpose allocator in the ker- nel. It is implemented on-top of the vmem(9) resource allocator (beyond the scope of this document), meaning it will be using pool_cache(9) inter- nally to speed-up common (small) sized allocations. It requires no setup, but cannot be used from interrupt context. See kmem(9) for more details. The Pool Allocator The pool(9) allocator is a fixed-size memory allocator. It requires setup (to initialize a memory pool) and is interrupt-safe. See pool(9) for more details. The Pool Cache Allocator The pool cache allocator works on-top of the pool(9) allocator, also allowing fixed-size allocation only, requires setup, and is interrupt- safe. The pool cache allocator is expected to be faster than other allocators, including the ``normal'' pool allocator. In the future this allocator is expected to have a per-CPU cache. See pool_cache(9) for more details. The UVM Kernel Memory Allocator This is a low-level memory allocator interface. It allows variable-sized allocations in multiples of PAGE_SIZE, and can be used to allocate both wired and pageable kernel memory. See uvm(9) for more details. SEE ALSO
intro(9), kmem(9), pool(9), pool_cache(9), uvm(9), vmem(9) AUTHORS
Elad Efrat <elad@NetBSD.org> YAMAMOTO Takashi <yamt@NetBSD.org> BSD
August 3, 2009 BSD

Check Out this Related Man Page

UVM_KM(9)						   BSD Kernel Developer's Manual						 UVM_KM(9)

NAME
uvm_km -- raw kernel memory or address space allocator SYNOPSIS
#include <sys/param.h> #include <uvm/uvm.h> vaddr_t uvm_km_alloc(struct vm_map *map, vsize_t size, vsize_t align, uvm_flag_t flags); void uvm_km_free(struct vm_map *map, vaddr_t addr, vsize_t size, uvm_flag_t flags); struct vm_map * uvm_km_suballoc(struct vm_map *map, vaddr_t *min, vaddr_t *max, vsize_t size, int flags, bool fixed, struct vm_map_kernel *submap); DESCRIPTION
The UVM facility for allocation of kernel memory or address space in pages. Both wired and pageable memory can be allocated by this facil- ity, as well as kernel address space. Note that this is a raw allocator. For general purpose memory allocation, kmem(9) interface should be used. FUNCTIONS
uvm_km_alloc() allocates size bytes of kernel memory in map map. The first address of the allocated memory range will be aligned according to the align argument (specify 0 if no alignment is necessary). The alignment must be a multiple of page size. The flags is a bitwise inclusive OR of the allocation type and operation flags. The allocation type should be one of: UVM_KMF_WIRED Wired memory. UVM_KMF_PAGEABLE Demand-paged zero-filled memory. UVM_KMF_VAONLY Virtual address only. No physical pages are mapped in the allocated region. If necessary, it is the caller's responsibil- ity to enter page mappings. It is also the caller's responsibility to clean up the mappings before freeing the address range. The following operation flags are available: UVM_KMF_CANFAIL Can fail even if UVM_KMF_NOWAIT is not specified and UVM_KMF_WAITVA is specified. UVM_KMF_ZERO Request zero-filled memory. Only supported for UVM_KMF_WIRED. Should not be used with other types. UVM_KMF_TRYLOCK Fail if cannot lock the map without sleeping. UVM_KMF_NOWAIT Fail immediately if no memory is available. UVM_KMF_WAITVA Sleep to wait for the virtual address resources if needed. If neither UVM_KMF_NOWAIT nor UVM_KMF_CANFAIL are specified and UVM_KMF_WAITVA is specified, uvm_km_alloc() will never fail, but rather sleep indefinitely until the allocation succeeds. Pageability of the pages allocated with UVM_KMF_PAGEABLE can be changed by uvm_map_pageable(). In that case, the entire range must be changed atomically. Changing a part of the range is not supported. uvm_km_free() frees the memory range allocated by uvm_km_alloc(). addr must be an address returned by uvm_km_alloc(). map and size must be the same as the ones used for the corresponding uvm_km_alloc(). flags must be the allocation type used for the corresponding uvm_km_alloc(). Note that uvm_km_free() is the only way to free memory ranges allocated by uvm_km_alloc(). uvm_unmap() must not be used. uvm_km_suballoc() allocates submap from map, creating a new map if submap is NULL. The addresses of the submap can be specified explicitly by setting the fixed argument to true, which causes the min argument to specify the beginning of the address in the submap. If fixed is false, any address of size size will be allocated from map and the start and end addresses returned in min and max. The flags are used to initialize the created submap. The following flags can be set: VM_MAP_PAGEABLE Entries in the map may be paged out. VM_MAP_INTRSAFE Map should be interrupt-safe. VM_MAP_TOPDOWN A top-down mapping should be arranged. SEE ALSO
kmem(9), pmap(9), pool_cache(9), uvm(9), uvm_map(9), vmem(9) HISTORY
UVM and uvm_km first appeared in NetBSD 1.4. BSD
June 3, 2011 BSD
Man Page