Basic Linux Concepts

Source: Internet
Author: User

Linux divides physical memory into fixed, uniform-sized blocks called page frames, typically 4KB.

Linux uses 4KB page frame size as the standard physical memory allocation unit, the kernel uses the data structure page to describe a page box state information, actually the page is the process concept, the page box contains the page

The page descriptor that uses the struct page in the Linux kernel represents the state of the page box, and each physical page box corresponds to a page struct, which is the pager descriptor. The page descriptor is organized in the form of an array, where the first address of the array exists in the struct pointer of Mem_map.

If you know the page frame number PFN You can get its physical address through pfn<<page_size, and the page box number can also be obtained by the corresponding page descriptor at the first address of pages page: (&page-mem_map)/sizeof (struct PAGE). This establishes the link between the physical page frame and the page descriptor ....

The physical page box corresponds to the Kernel's page (page descriptor) one by one

High-end memory area: The concept in the kernel linear address space (the linear address space in the kernel linear address (3g~4g range) above 896) We explained the origin of high-end memory. Linux divides the kernel address space into three parts ZONE_DMA, Zone_normal, and Zone_highmem, high-end memory High_mem address space range 0xf8000000 ~ 0xFFFFFFFF (896MB~1024MB)

The origin of high-end memory: (Simple is to use the internal linear space of high-end memory mapping of the remaining physical memory, low-end memory linear space directly mapped to physical memory, so that only the 1G linear space of the kernel state, you can access 4G of physical memory)

Assuming that the above simple address mapping relationship, then the kernel logical address space access is 0xc0000000 ~ 0xFFFFFFFF, then the corresponding physical memory range is 0x0 ~ 0x40000000, that is, only access to 1G of physical memory. If 8G physical memory is installed in the machine, the kernel will only be able to access the first 1G physical memory, and the 7G physical memory will be inaccessible because the kernel's address space has all been mapped to the physical memory address range 0x0 ~ 0x40000000. Even if 8G physical memory is installed, then the physical address is 0x40000001 memory, how to access the kernel? The code must have a memory linear address, 0xc0000000 ~ 0xFFFFFFFF of the address space has been exhausted, so the physical address 0x40000000 later memory can not be accessed.

High-end Memory mapping method (mapped using 128M of memory linear address space)

1. Permanent kernel mapping (void *kmp (struct page*page)

High-end memory and low-end memory are available

The kernel specifically leaves a linear space for this, from Pkmap_base to Fixaddr_start, to map high-end memory. On the 2.6 kernel, this address range is 4g-8m to 4g-4m. This space is called the "kernel permanent mapping Space" or "permanent kernel mapping Space". This space and other space use the same page catalog table, for the kernel, is swapper_pg_dir, for ordinary processes, through the CR3 register point. Typically, this space is 4M in size, so just a page table is needed, and the kernel looks for the page table by pkmap_page_table. With Kmap (), you can map a page to this space. Since this space is 4M in size, you can map up to 1024 page at a time. Therefore, for unused page, and should be released from this space (that is, to de-map), through Kunmap (), a page corresponding to the linear address from the space release.

2. Temporary kernel mapping

3. Non-contiguous zone memory management

Basic Linux Concepts

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.