Next: Various terms used in
Up: Introduction
Previous: Introduction
It is
helpfull to have a overall theoretical view of the system before we do any real
analysis of code or algorithm. First we will see about the various types of
memory addresses used by the kernel.
- Physical address - The memory as known by the low-level hardware.
- Direct-mapped kernel virtual address - The physical address
applied an offset.(This also is different in some architectures).
- Pure kernel virtual address - The address that can be dereferenced by
the kernel, but which does not map into physical address directly. i.e., cannot
dereferenced just by offsetting as in the case of Direct-mapped KVA
- User virtual address - The address as seen by user space programs
All of the physical memory is mapped to the upper one GB of kernel
virtual memory. This is the reason kernel is able to use only 1GB of physical
memory. But this is addressed and solved by the himem logic.
Next we will see in breif about the most basic algorithms used in the MM
sub-system.
- The kernel memory map uses 4m pages in Pentium architecture. The normal
virtual memory in linux is maintained as 4k pages.
- Memory is logically
split into various zones. The split is different in each machine and depends,
among other things,on the amount of memory we have.
- The physical memory is
served by the Buddy allocator(name because it uses the buddy algorithm). The
size of page served by the buddy allocator is 4k. The buddy system keeps in mind
about the various zones of memory. Therefore it effectively becomes a zoned
buddy allocator.
- The slab allocator is used by the kernel to allocate in-kernel memory. It
is dynamically allocated memory and uses the "slab allcation algorithm". Slabs
are built on top of physical pages allocated by the buddy allocator. The memory
allocated by the slab allocator is contiguous
- The slab allocator provides dynamic memory upto 128 KB. When memory is
needed grater than this size it is reserved at boot time itself. In other words
you have to plan well ahead and allcoation is done at when the page tables are
setup at boot time.
- When memory grater than 128k chunks are needed and you are not bothered
weather it is physically contiguous or not, we can use the vmalloc allocator.
This allocates virtually contiguous memory that may or may-not be physically
contigoues.
- Memory is allocated to the user space programs by data segment adjustment
(by sys_brk call) and then by servicing the page fault that arises when the
user-space app tries to access that page.
Next: Various terms used in
Up: Introduction
Previous: Introduction
2002-09-22