Mapping

Another important element of the page descriptor is a pointer *mapping of type struct address_space. However, this is one of the tricky pointers which might either refer to an instance of struct address_space, or to an instance of struct anon_vma. Before we get into details of how this is achieved, let's first understand the importance of those structures and the resources they represent.

Filesystems engage free pages( from page cache) to cache data of recently accessed disk files. This mechanism helps minimize disk I/O operations: when file data in the cache is modified, the appropriate page is marked dirty by setting the PG_dirty bit; all dirty pages are written to the corresponding disk block by scheduling disk I/O at strategic intervals. struct address_space is an abstraction that represents a set of pages engaged for a file cache. Free pages of the page cache can also be mapped to a process or process group for dynamic allocations, pages mapped for such allocations are referred to as anonymous page mappings. An instance of struct anon_vma represents a memory block created with anonymous pages, that are mapped to the virtual address space (through VMA instance) of a process or processes.

The tricky dynamic initialization of the pointer with address to either of the data structures is achieved by bit manipulations. If low bit of pointer *mapping is clear, then it is an indication that the page is mapped to an inode and the pointer refers to struct address_space. If low bit is set, it is an indication for anonymous mapping, which means the pointer refers to an instance of struct anon_vma. This is made possible by ensuring allocation of address_space instances aligned to sizeof(long), which makes the least significant bit of a pointer to address_space be unset (that is, set to 0).

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

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