UVM Analysis of NetBSD memory management system

Source: Internet
Author: User

Review

UVM is a virtual memory system used by NetBSD. Unlike other 4.4BSD based systems such as FreeBSD, it completely rewrites the 4.4BSD VM. Compared to the 4.4BSD VM, it has a number of notable improvements. It simplifies the design, improves the efficiency, especially introduces the AMAP, and solves the cow problem well.

The UVM system is relatively independent of the system kernel (4.4BSD VM is based on the Mach VM, separated from the Mach microkernel, and 4.4BSD and NetBSD are integrated with this functional module structure, although they do not use the microkernel architecture). All code in the code tree SRC/SYS/UVM, the file path mentioned below is not an absolute path, but a path from that directory.

Core Data structure

In NetBSD, each process has a separate process space. This is represented by the vmspace structure, where each proc interface contains an item p_vmsapce that performs Vmspace, which is the interface between the UVM system and the process management system.

The statement of Vmspace structure in Uvm_extern.h, we see that, in addition to some audit information, it directly points to the UVM_MAP structure in Uvm_map.h. Therefore, the UVM_MAP structure is representative of an address space, as the name implies, to complete the mapping of the address (mapping function). Two of the most important items in Uvm_map are bidirectional linked lists that point to the hardware-related address space description structure Pmap and uvm_map_entry.

We'll look at the uvm_map_entry structure carefully in the next section and deal with it often later. Here, we see that its start and end entries illustrate the range of addresses this entry maps into address spaces, followed by a joint object that points to uvm_obj or Sub_map, Sub_map is a special mechanism provided to the kernel address space, and I They seldom discuss it. So to speak, uvm_map_entry points to a uvm_obj structure, which is the mapping of that object. The offset item describes its offsets in the uvm_obj. PS. This is a very clear note written, I am here to say why ...

We can also see the Aref item, the VM_AREF structure points to a AMAP (anonymous object Map XXX.), which is a mechanism to replace the 4.4BSD multi-layer shadow object.

Uvm_obj, Vm_amap and the structure we call the underlying structure, the actual allocation and operation of memory is done at the following levels, and they end up pointing to the smallest unit vm_page of memory allocation management.

The entire UVM core data can be expressed as below, the dotted line between Vm_amap and Uvm_obj we will explain in the following chapters. Does not really represent a pointer reference relationship.

vmspace
   |
   v
uvm_map_entry <--> vm_map_entry ...
   |  |
   |  v
   |  vm_pmap
   |
   +-----------------+
   |         |
   v         |
 vm_aref       |
   |         |
   v         v
 vm_amap < - - - > uvm_obj
   |         |
   v         v
 vm_anon ...    vm_page <-> vm_page ...
   |
   v
 vm_page

In addition, we note that there is a UVM structure in the uvm.h, which is a collection of various UVM resources and parameters, and only one UVM object exists in the system.

Top-level mapping mechanism (vmspace, Uvm_map, Uvm_map_entry)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.