Linux Memory Management-high-end memory ing

Source: Internet
Author: User
Article title: Linux Memory Management-high-end memory ing method. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

High-end memory refers to the memory with a physical address greater than 896 MB.

For such memory, the ing cannot be performed in the "kernel direct ing space.

Why?

Because the "kernel direct ing space" can only be from 3G to 4G, and can only be mapped to 1G physical memory directly, there is nothing to do with physical memory larger than 1G.

In fact, the "kernel direct ing space" cannot reach 1 GB, and we have to leave some linear space for "kernel dynamic ing space.

Therefore, Linux requires that the "direct kernel ing space" can map up to 896 MB of physical memory.

For high-end memory, you can obtain the corresponding page through alloc_page () or other functions. but to access the actual physical memory, you have to convert the page into a linear address (why? Think about how MMU accesses the physical memory). That is to say, we need to find a linear space for the pages corresponding to the high-end memory. this process is called high-end memory ING.

There are three high-end memory ing methods:

1. ING to "kernel dynamic ing space"

This method is simple, because vmalloc () allows you to obtain pages from high-end memory when applying for memory in the "kernel dynamic ing space" (see vmalloc implementation ), therefore, high-end memory may be mapped to "kernel dynamic ing space.

2. permanent kernel ing

If alloc_page () is used to obtain the page corresponding to the high-end memory, how can we find a linear space for it?

The kernel sets aside a linear space from PKMAP_BASE to FIXADDR_START, which is used to map high-end memory. On the 2.4 kernel, the address range is 4G-8 M to 4G-4 M. This space is called "kernel permanent ing space" or "permanent kernel ing space"

   This space uses the same page directory table as other spaces. for the kernel, it is swapper_pg_dir. for common processes, it points to the table through the 33rd register.

Generally, the space is 4 MB, so only one page table is required. the kernel searches for this page table through pkmap_page_table.

With kmap (), you can map a page to this space.

   Because the space is 4 MB, up to 1024 pages can be mapped at the same time. Therefore, for unused pages, and should be released from this space (that is, the ing relationship is removed), through kunmap (), you can release the linear address of a page from this space.

3. temporary ing

The kernel reserves some linear space between FIXADDR_START and FIXADDR_TOP for special requirements. This space is called a "fixed ing space"

Some of this space is used for temporary ing of high-end memory.

This space has the following features:

   1, Space occupied by each CPU

   2, The space occupied by each CPU is divided into multiple small spaces. The size of each small space is one page, and each small space is used for one purpose. these purposes are defined in km_type in kmap_types.h.

To perform a temporary ing, you need to specify the ing purpose. based on the ing purpose, you can find the corresponding small space and use the address of the space as the ing address. This means that a temporary ING will overwrite the previous ING.

You can use kmap_atomic () to implement temporary ING.

Simple and simple expression of how to map high-end memory

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.