Linux Virtual Memory Subsystem

Allocating Kernel Memory

Allocating Kernel Memory


There are several different methods of allocating kernel memory at runtime.

  • The bootmem allocator is used to reserve pages for static kernel data during the early boot process.

  • alloc_pages() is the basic interface to the zone allocator, which hands you a page struct representing a (range of) physical pages.

  • get_free_pages() is a slightly nicer interface to alloc_pages() which returns the virtual address in kernel memory, rather than a page struct pointer. get_free_pages() only works for low memory. [This is not enforced, but it looks like if you call get_free_pages() with GFP_HIGHMEM, Bad Things can happen.]

  • kmalloc() is the slab allocator, which uses the zone allocator to whack off chunks of kernel physically-mapped-virtual pages, and carves them up into smaller bits for particular uses.

  • vmalloc() allocates arbitrary physical pages and maps them into kernel VM contiguously.

  • kmap() temporarily maps *any* physical page into kernel VM.


Physical MM

Linux MM Outline

The Page Cache


Questions and comments to Joe Knapka

The http://kneuro.net/cgi-bin/lxr/http/source links in this page were produced by lxrreplace.tcl, which is available for free.

Credits


Last changed:
01-25-06 09:25:04


This page was rendered by LittleSite.
All content Copyright (c) 2005 by J.Knapka.
Questions and comments to JK