In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail what pfn means in linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
In linux, the full name of pfn is "page frame number", which is the number of physical memory areas. "page frame" is for physical memory, dividing physical memory into page size regions and numbering each page, and this number is PFN.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
1. What is page frame?
One of the most important functions of the operating system is to manage all kinds of resources in the computer system. As the most important resource: memory, we must manage it. In the linux operating system, physical memory is managed according to page size, how much page size is related to hardware and linux system configuration, 4k is the most classic setting. Therefore, for physical memory, we divide it into page arranged by page size, and the memory area of each page size in physical memory is called page frame. We build a struct page data structure for each physical page frame to track the usage of each physical page: is it the body segment for the kernel? Or the page table used for the process? Whether it is used for all kinds of file cache or in free state.
Each page frame has an one-to-one corresponding page data structure. The macros of page_to_pfn and pfn_to_page are defined in the system to convert between page frame number and page data structures. How to convert is related to memory modle. We will describe three memory models in linux kernel in detail in the third chapter.
2. What is PFN?
For a computer system, the entire physical address space should be a section of address space starting from 0 to the maximum physical space that the actual system can support. In ARM system, if the physical address is 32 bit, then the physical address space is 4G. In ARM64 system, if the number of physical address bit is 48, then the physical address space is 256T. Of course, in fact, not all such a large physical address space is used for memory, and some of them belong to the Imax O space (of course, some cpu arch have their own independent io address space). Therefore, the physical address space occupied by memory should be a limited range, and it is impossible to cover the entire physical address space. However, due to the increasing amount of memory, 4G physical address space can no longer meet the memory requirements for 32-bit systems, so there will be the concept of high memory, which will be described in detail later.
PFN is the abbreviation of page frame number, the so-called page frame, is for physical memory, physical memory is divided into page size areas, and give each page number, this number is PFN. Assuming that physical memory starts at address 0, the page frame where PFN equals 0 is the page at which address 0 (physical address) begins. Assuming that physical memory starts with the x address, the first page frame number is (x > > PAGE_SHIFT).
The value range of PFN is 0 Murray-(memory size > > 12).
However, due to the physical memory mapping, the 0 address of the physical memory corresponds to 0 that is not the physical address on the system. For example, on s3c2440, the address of memory starts with 0x30000000. When connecting to ram, the 0 address of ram is, in s3c2440's view, 0x30000000. So the value of pfn in the system should be equal to (physical address-memory base address) > > 12.
But in linux, virtual addresses are all used, so it is necessary to convert virtual address to physical address first. So there is a macro definition in linux that translates the virtual address and pfn of the kernel linear space:
# define virt_to_pfn (kaddr) (_ _ pa (kaddr) > > PAGE_SHIFT) / / _ _ pa () converts a virtual address to a physical address # define pfn_to_virt (pfn) _ _ va ((pfn))
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 223
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.