Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vmalloc.h File Reference
#include <linux/spinlock.h>
#include <linux/init.h>
#include <asm/page.h>

Go to the source code of this file.

Data Structures

struct  vm_struct
 

Macros

#define VM_IOREMAP   0x00000001 /* ioremap() and friends */
 
#define VM_ALLOC   0x00000002 /* vmalloc() */
 
#define VM_MAP   0x00000004 /* vmap()ed pages */
 
#define VM_USERMAP   0x00000008 /* suitable for remap_vmalloc_range */
 
#define VM_VPAGES   0x00000010 /* buffer for pages was vmalloc'ed */
 
#define VM_UNLIST   0x00000020 /* vm_struct is not listed in vmlist */
 
#define IOREMAP_MAX_ORDER   (7 + PAGE_SHIFT) /* 128 pages */
 

Functions

void vm_unmap_ram (const void *mem, unsigned int count)
 
voidvm_map_ram (struct page **pages, unsigned int count, int node, pgprot_t prot)
 
void vm_unmap_aliases (void)
 
voidvmalloc (unsigned long size)
 
voidvzalloc (unsigned long size)
 
voidvmalloc_user (unsigned long size)
 
voidvmalloc_node (unsigned long size, int node)
 
voidvzalloc_node (unsigned long size, int node)
 
voidvmalloc_exec (unsigned long size)
 
voidvmalloc_32 (unsigned long size)
 
voidvmalloc_32_user (unsigned long size)
 
void__vmalloc (unsigned long size, gfp_t gfp_mask, pgprot_t prot)
 
void__vmalloc_node_range (unsigned long size, unsigned long align, unsigned long start, unsigned long end, gfp_t gfp_mask, pgprot_t prot, int node, const void *caller)
 
void vfree (const void *addr)
 
voidvmap (struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
 
void vunmap (const void *addr)
 
int remap_vmalloc_range (struct vm_area_struct *vma, void *addr, unsigned long pgoff)
 
void vmalloc_sync_all (void)
 
struct vm_structget_vm_area (unsigned long size, unsigned long flags)
 
struct vm_structget_vm_area_caller (unsigned long size, unsigned long flags, const void *caller)
 
struct vm_struct__get_vm_area (unsigned long size, unsigned long flags, unsigned long start, unsigned long end)
 
struct vm_struct__get_vm_area_caller (unsigned long size, unsigned long flags, unsigned long start, unsigned long end, const void *caller)
 
struct vm_structremove_vm_area (const void *addr)
 
struct vm_structfind_vm_area (const void *addr)
 
int map_vm_area (struct vm_struct *area, pgprot_t prot, struct page ***pages)
 
struct vm_structalloc_vm_area (size_t size, pte_t **ptes)
 
void free_vm_area (struct vm_struct *area)
 
long vread (char *buf, char *addr, unsigned long count)
 
long vwrite (char *buf, char *addr, unsigned long count)
 
__init void vm_area_add_early (struct vm_struct *vm)
 
__init void vm_area_register_early (struct vm_struct *vm, size_t align)
 

Variables

rwlock_t vmlist_lock
 
struct vm_structvmlist
 

Macro Definition Documentation

#define IOREMAP_MAX_ORDER   (7 + PAGE_SHIFT) /* 128 pages */

Definition at line 24 of file vmalloc.h.

#define VM_ALLOC   0x00000002 /* vmalloc() */

Definition at line 12 of file vmalloc.h.

#define VM_IOREMAP   0x00000001 /* ioremap() and friends */

Definition at line 11 of file vmalloc.h.

#define VM_MAP   0x00000004 /* vmap()ed pages */

Definition at line 13 of file vmalloc.h.

#define VM_UNLIST   0x00000020 /* vm_struct is not listed in vmlist */

Definition at line 16 of file vmalloc.h.

#define VM_USERMAP   0x00000008 /* suitable for remap_vmalloc_range */

Definition at line 14 of file vmalloc.h.

#define VM_VPAGES   0x00000010 /* buffer for pages was vmalloc'ed */

Definition at line 15 of file vmalloc.h.

Function Documentation

struct vm_struct* __get_vm_area ( unsigned long  size,
unsigned long  flags,
unsigned long  start,
unsigned long  end 
)
read

Definition at line 1376 of file vmalloc.c.

struct vm_struct* __get_vm_area_caller ( unsigned long  size,
unsigned long  flags,
unsigned long  start,
unsigned long  end,
const void caller 
)
read

Definition at line 1384 of file vmalloc.c.

void* __vmalloc ( unsigned long  size,
gfp_t  gfp_mask,
pgprot_t  prot 
)

Definition at line 223 of file nommu.c.

void* __vmalloc_node_range ( unsigned long  size,
unsigned long  align,
unsigned long  start,
unsigned long  end,
gfp_t  gfp_mask,
pgprot_t  prot,
int  node,
const void caller 
)

__vmalloc_node_range - allocate virtually contiguous memory : allocation size : desired alignment : vm area range start : vm area range end : flags for the page level allocator : protection mask for the allocated pages : node to use for allocation or -1 : caller's return address

Allocate enough pages to cover from the page level allocator with flags. Map them into contiguous kernel virtual space, using a pagetable protection of .

Definition at line 1660 of file vmalloc.c.

struct vm_struct* alloc_vm_area ( size_t  size,
pte_t **  ptes 
)
read

alloc_vm_area - allocate a range of kernel address space : size of the area

Returns: NULL on failure, vm_struct on success

This function reserves a range of kernel address space, and allocates pagetables to map that range. No actual mappings are created. If the kernel address space is not shared between processes, it syncs the pagetable across all processes.

alloc_vm_area - allocate a range of kernel address space : size of the area : returns the PTEs for the address space

Returns: NULL on failure, vm_struct on success

This function reserves a range of kernel address space, and allocates pagetables to map that range. No actual mappings are created.

If is non-NULL, pointers to the PTEs (in init_mm) allocated for the VM area are returned.

Definition at line 457 of file nommu.c.

struct vm_struct* find_vm_area ( const void addr)
read

find_vm_area - find a continuous kernel virtual area : base address

Search for the kernel VM area starting at , and return it. It is up to the caller to do all required locking to keep the returned pointer valid.

Definition at line 1422 of file vmalloc.c.

void free_vm_area ( struct vm_struct area)

Definition at line 464 of file nommu.c.

struct vm_struct* get_vm_area ( unsigned long  size,
unsigned long  flags 
)
read

get_vm_area - reserve a contiguous kernel virtual area : size of the area : VM_IOREMAP for I/O mappings or VM_ALLOC

Search an area of in the kernel virtual mapping area, and reserved it for out purposes. Returns the area descriptor on success or NULL on failure.

Definition at line 1401 of file vmalloc.c.

struct vm_struct* get_vm_area_caller ( unsigned long  size,
unsigned long  flags,
const void caller 
)
read

Definition at line 1407 of file vmalloc.c.

int map_vm_area ( struct vm_struct area,
pgprot_t  prot,
struct page ***  pages 
)

Definition at line 1270 of file vmalloc.c.

int remap_vmalloc_range ( struct vm_area_struct vma,
void addr,
unsigned long  pgoff 
)

remap_vmalloc_range - map vmalloc pages to userspace : vma to cover (map full range of vma) : vmalloc memory : number of pages into addr before first page to map

Returns: 0 for success, -Exxx on failure

This function checks that addr is a valid vmalloc'ed area, and that it is big enough to cover the vma. Will return failure if that criteria isn't met.

Similar to remap_pfn_range() (see mm/memory.c)

Definition at line 1819 of file nommu.c.

struct vm_struct* remove_vm_area ( const void addr)
read

remove_vm_area - find and remove a continuous kernel virtual area : base address

Search for the kernel VM area starting at , and remove it. This function returns the found VM area, but using it is NOT safe on SMP machines, except for its size or flags.

Definition at line 1441 of file vmalloc.c.

void vfree ( const void addr)

vfree - release memory allocated by vmalloc() : memory base address

Free the virtually continuous memory area starting at , as obtained from vmalloc(), vmalloc_32() or __vmalloc(). If is NULL, no operation is performed.

Must not be called in interrupt context.

Definition at line 217 of file nommu.c.

__init void vm_area_add_early ( struct vm_struct vm)

vm_area_add_early - add vmap area early during boot : vm_struct to add

This function is used to add fixed kernel vm area to vmlist before vmalloc_init() is called. ->addr, ->size, and ->flags should contain proper values and the other fields should be zero.

DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.

Definition at line 1138 of file vmalloc.c.

__init void vm_area_register_early ( struct vm_struct vm,
size_t  align 
)

vm_area_register_early - register vmap area early during boot : vm_struct to register : requested alignment

This function is used to register kernel vm area before vmalloc_init() is called. ->size and ->flags should contain proper values on entry and other fields should be zero. On return, vm->addr contains the allocated address.

DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.

Definition at line 1166 of file vmalloc.c.

void* vm_map_ram ( struct page **  pages,
unsigned int  count,
int  node,
pgprot_t  prot 
)

vm_map_ram - map pages linearly into kernel virtual address (vmalloc space) : an array of pointers to the pages to be mapped : number of pages : prefer to allocate data structures on this node : memory protection to use. PAGE_KERNEL for regular RAM

Returns: a pointer to the address that has been mapped, or NULL on failure

Definition at line 419 of file nommu.c.

void vm_unmap_aliases ( void  )

vm_unmap_aliases - unmap outstanding lazy aliases in the vmap layer

The vmap/vmalloc layer lazily flushes kernel virtual mappings primarily to amortize TLB flushing overheads. What this means is that any page you have now, may, in a former life, have been mapped into kernel virtual address by the vmap layer and so there might be some CPUs with TLB entries still referencing that page (additional to the regular 1:1 kernel mapping).

vm_unmap_aliases flushes all such lazy mappings. After it returns, we can be sure that none of the pages we have control over will have any aliases from the vmap layer.

Definition at line 432 of file nommu.c.

void vm_unmap_ram ( const void mem,
unsigned int  count 
)

vm_unmap_ram - unmap linear kernel address space set up by vm_map_ram : the pointer returned by vm_map_ram : the count passed to that vm_map_ram call (cannot unmap partial)

Definition at line 426 of file nommu.c.

void* vmalloc ( unsigned long  size)

vmalloc - allocate virtually contiguous memory : allocation size Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 292 of file nommu.c.

void* vmalloc_32 ( unsigned long  size)

vmalloc_32 - allocate virtually contiguous memory (32bit addressable) : allocation size

Allocate enough 32bit PA addressable pages to cover from the page level allocator and map them into continguos kernel virtual space.

vmalloc_32 - allocate virtually contiguous memory (32bit addressable) : allocation size

Allocate enough 32bit PA addressable pages to cover from the page level allocator and map them into contiguous kernel virtual space.

Definition at line 380 of file nommu.c.

void* vmalloc_32_user ( unsigned long  size)

vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory : allocation size

The resulting memory area is 32bit addressable and zeroed so it can be mapped to userspace without leaking data.

VM_USERMAP is set on the corresponding VMA so that subsequent calls to remap_vmalloc_range() are permissible.

vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory : allocation size

The resulting memory area is 32bit addressable and zeroed so it can be mapped to userspace without leaking data.

Definition at line 396 of file nommu.c.

void* vmalloc_exec ( unsigned long  size)

vmalloc_exec - allocate virtually contiguous, executable memory : allocation size

Kernel-internal function to allocate enough pages to cover the page level allocator and map them into contiguous and executable kernel virtual space.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 368 of file nommu.c.

void* vmalloc_node ( unsigned long  size,
int  node 
)

vmalloc_node - allocate memory on a specific node : allocation size : numa node

Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 328 of file nommu.c.

void vmalloc_sync_all ( void  )

Definition at line 868 of file fault.c.

void* vmalloc_user ( unsigned long  size)

vmalloc_user - allocate zeroed virtually contiguous memory for userspace : allocation size

The resulting memory area is zeroed so it can be mapped to userspace without leaking data.

Definition at line 233 of file nommu.c.

void* vmap ( struct page **  pages,
unsigned int  count,
unsigned long  flags,
pgprot_t  prot 
)

vmap - map an array of pages into virtually contiguous space : array of page pointers : number of pages to map : vm_area->flags : page protection for the mapping

Maps pages from into contiguous kernel virtual space.

Definition at line 406 of file nommu.c.

long vread ( char buf,
char addr,
unsigned long  count 
)

vread() - read vmalloc area in a safe way. : buffer for reading data : vm address. : number of bytes to be read.

Returns # of bytes which addr and buf should be increased. (same number to ). Returns 0 if [addr...addr+count) doesn't includes any intersect with alive vmalloc area.

This function checks that addr is a valid vmalloc'ed area, and copy data from that area to a given buffer. If the given memory range of [addr...addr+count) includes some valid address, data is copied to proper area of . If there are memory holes, they'll be zero-filled. IOREMAP area is treated as memory hole and no copy is done.

If [addr...addr+count) doesn't includes any intersects with alive vm_struct area, returns 0. should be kernel's buffer.

Note: In usual ops, vread() is never necessary because the caller should know vmalloc() area is valid and can use memcpy(). This is for routines which have to access vmalloc area without any informaion, as /dev/kmem.

Definition at line 265 of file nommu.c.

void vunmap ( const void addr)

vunmap - release virtual mapping obtained by vmap() : memory base address

Free the virtually contiguous memory area starting at , which was created from the page array passed to vmap().

Must not be called in interrupt context.

Definition at line 413 of file nommu.c.

long vwrite ( char buf,
char addr,
unsigned long  count 
)

vwrite() - write vmalloc area in a safe way. : buffer for source data : vm address. : number of bytes to be read.

Returns # of bytes which addr and buf should be incresed. (same number to ). If [addr...addr+count) doesn't includes any intersect with valid vmalloc area, returns 0.

This function checks that addr is a valid vmalloc'ed area, and copy data from a buffer to the given addr. If specified range of [addr...addr+count) includes some valid address, data is copied from proper area of . If there are memory holes, no copy to hole. IOREMAP area is treated as memory hole and no copy is done.

If [addr...addr+count) doesn't includes any intersects with alive vm_struct area, returns 0. should be kernel's buffer.

Note: In usual ops, vwrite() is never necessary because the caller should know vmalloc() area is valid and can use memcpy(). This is for routines which have to access vmalloc area without any informaion, as /dev/kmem.

Definition at line 271 of file nommu.c.

void* vzalloc ( unsigned long  size)

vzalloc - allocate virtually contiguous memory with zero fill : allocation size Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space. The memory allocated is set to zero.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 310 of file nommu.c.

void* vzalloc_node ( unsigned long  size,
int  node 
)

vzalloc_node - allocate memory on a specific node with zero fill : allocation size : numa node

Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space. The memory allocated is set to zero.

For tight control over page level allocator and protection flags use __vmalloc() instead.

vzalloc_node - allocate memory on a specific node with zero fill : allocation size : numa node

Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space. The memory allocated is set to zero.

For tight control over page level allocator and protection flags use __vmalloc_node() instead.

Definition at line 346 of file nommu.c.

Variable Documentation

struct vm_struct* vmlist

Definition at line 215 of file nommu.c.

rwlock_t vmlist_lock