Linux memory application, method principle Summary

Source: Internet
Author: User
Linux memory application, method principle Summary-Linux general technology-Linux programming and kernel information, the following is a detailed description. 1. address space management

Physical addresses are managed by the kernel. node --> zone --> mem_map --> page, all physical pages correspond to page frames in the mem_map array, and different pages are divided into DMA, normal and highmem zones.

The Kernel linear address space, in fact, only the low-end memory has a linear address, 0---896MB.

The virtual address of the kernel. The virtual address of the low-end memory is the same as the linear address. High-end memory only has virtual addresses after ing

User space address, tast_struct ---> mmap --> mm_struct ---> vm_area_struct

2. Memory application or use

The allocation of physical memory will eventually call _ alloc_pages () in the kernel (). it is the core allocation function. The applied MAX_ORDER power cannot exceed 2. It seems that the maximum size is 4 MB.

Linear address: kmalloc and get_free_pages. The corresponding physical memory is the low-end memory. kmalloc is based on slab allocation technology and cannot exceed kb.

Virtual Address, applied for by vmalloc. it just creates a virtual memory space similar to the vm_area of the user space in the kernel to vmlist, and the final physical memory allocation is still based on the missing page.

The virtual memory of the user space, such as malloc, will eventually be do_map () and do_brk () in the kernel (). In fact, it only creates a virtual space, and the final physical memory is allocated when the page is missing.

3. Memory Switching

Both the page Structure and the vm_area_struct structure of the user layer contain the locked and reserved flags. You can set these labels in a proper way. The page locks are stored in the physical memory and are not exchanged.

4. The device memory can be mapped to the kernel virtual address space through ioremap or the user space through mmap.
Related Article

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.