Page descriptor

Page frames are the smallest possible allocation units of memory and kernel needs to utilize them for all its memory needs. Some page frames would be required for mapping physical memory to virtual address spaces of user mode processes, some for kernel code and its data structures, and some for processing dynamic allocation requests raised by process or a kernel service. For efficient management of such operations, kernel needs to distinguish between page frames currently in use from those which are free and available. This purpose is achieved through an architecture-independent data structure called struct page, which is defined to hold all meta data pertaining to a page frame, including its current state. An instance of struct page is allocated for each physical page frame found, and kernel has to maintain a list of page instances in main memory all the time.

Page structure is one of the heavily used data structures of the kernel, and is referred from various kernel code paths. This structure is populated with diverse elements, whose relevance is entirely based on the state of the physical frame. For instance, specific members of page structure specify if corresponding physical page is mapped to virtual address space of a process, or a group of process. Such fields are not considered valid when the physical page has been reserved for dynamic allocations. To ensure that page instance in memory is allocated only with relevant fields, unions are heavily used to populate member fields. This is a prudent choice, since it enables cramming more information into the page structure without increasing its size in memory:

/*include/linux/mm-types.h */ 
/* The objects in struct page are organized in double word blocks in
* order to allows us to use atomic double word operations on portions
* of struct page. That is currently only used by slub but the arrangement
* allows the use of atomic double word operations on the flags/mapping
* and lru list pointers also.
*/
struct page {
/* First double word block */
unsigned long flags; /* Atomic flags, some possibly updated asynchronously */ union {
struct address_space *mapping;
void *s_mem; /* slab first object */
atomic_t compound_mapcount; /* first tail page */
/* page_deferred_list().next -- second tail page */
};
....
....

}

Following is a brief description of important members of page structure. Note that a lot of the details here assume your familiarity with other aspects of memory subsystem which we discuss in further sections of this chapter, such as memory allocators, page tables, and so forth. I recommend new readers to skip and revisit this section after you get acquainted with the necessary prerequisites.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.108.9