Sunday, May 17, 2009

Memory Mapping

2 kinds of pages: anonymous pages (pure RAM) and file mapped pages (backed by a file on disk/blk device). 2 levels of pages: physical and logical structure.

anonymous pages have mapping=NULL, mapped pages have mapping=addr_space. mapped pages also form a radix tree under the addr spc object.

the layer above page layer is the memory region layer. that layer keeps some flag to specify the kind of pages underneath.

initially, the memory region is not linked with the page frames. during page faults, the mem reg gets pages (anon, map). during page reclaim the link is broken temporarily.

the processes use file object. the memory region links the file object to the (logical) pages. if the pages are anon, then mem reg does not use the 'vm_pgoff' and 'vm_file'. but if the pages are mapped, then 'vm_file'=file object, 'vm_pgoff'=location in the file.

the address_space object links the physical pages and the virtual memory regions associated with a file.
  • page_tree member is the radix tree of physical pages (the page cache)
  • i_mmap is the radix priority search tree (PST) of the memory regions objects. PST is used for reverse mapping.
mapping (address space) has the host field pointing to the inode. file object->f_mapping = address space. one object on disk is one address space object. different modes of files are tracked by the file objects.

if vma_area_struct.vm_file is NULL then this region does not map any file.

if a memory region does not map a file, its nopage method is NULL (anonymous mapping).

No comments:

Post a Comment