Summary of Linux memory management skills

Source: Internet
Author: User
Article Title: Linux memory management skills summary. 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.

1 mem_map [PAGING_PAGES] Why does the array not start to record directly from the primary storage area, but starts to record from 1 m, and then sets the content between 1 m and the primary storage area to 100

2 mem_map [I] when it is larger than 1: the same physical page is shared by n (n> 1) linear addresses. For example, copy_page_table () will affect the value here.

3. Where do I need to execute the refresh page transform buffer (implemented by the invalidate () function ):

3.1 free_page_tables ()

3.2 copy_page_tables ()

3.3 un_wp_page ()

3.4 try_to_share ()

Change page Directory items loose table items

4. Related functions copied during writing

4.1 copy_page_tables (): Set the original and new page Directory items and page table items to read-only.

4.2 do_wp_page (): page write protection Handler

4.3 un_wp_page (): determines whether the page is shared. If not, set the page to writable and exit. If the page is shared, you need to apply for a new page and copy the content of the written page for the write process to cancel sharing.

5 COPY_SPACE (addr) does not understand

6 In the free_page_table () function, if the page where addr (physical address) is located is composed of n (n> = 2) linear address sharing (the copy_page_table function allows a physical page to be shared by multiple linear addresses). When the addr page is released, run mem_map [addr] -- (mm/memory. after the c Line 96) Statement, the value of mem_map [addr] cannot be changed to 0, but to n-1, which does not mean that the physical page has been released, should it be changed to mem_map [addr] = 0 (mm/memory. c Line 96? I thought it wrong.

7. Obtain the physical address of the page Directory corresponding to the linear address addr.

Dir = (unsigned long *) (addr> 20) & 0 xffc)

Note: first, addr> 22 gets the number of items in the corresponding page directory in the page Directory table, that is, the offset in the table, because the starting address of the page Directory table is physical address 0, the size of each item is 4 bytes. Therefore, the actual physical address is addr> 20, because only 20 digits are shifted to the right, and the last two digits are the content of the page table items, so we can block the last two digits with 0xffc to get the final result.

8. Obtain the physical address of the page table corresponding to the linear address addr.

Table = (unsigned long *) (address> 0) & oxffc) + (0xfffff000 & * (unsigned long *) (address> 20 & 0 xffc )))))

That is, offset + base address, refer to 7

Some of the problems have not been resolved, if the text is found wrong, or put forward suggestions, sent to: xuyufei13@gmail.com

(Kernel source code version 0.11)

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.