Chapter3:MemoryManagement
mm/highmem.c
void *page_address(struct page *page)Figure 3-41 outlines the interplay between the above data structures.struct page_address_map
page_address_map->virtual
page_address_map->pageLAST_
PKMAP
pkmap_countpage_address_htablemem_mapPKMAP_
BASELAST_
PKMAPFIXMAP_
STARTVirtual address space
00
1
212Figure 3-41: Data structures for managing persistent mappings.Finding Page Addresses
page_addressfirst checks whether the passedpageinstance is in normal memory or high memory. If the
former applies, the page address can be calculated from the position ofpagein themem_maparray. In the
latter case, the above hash table is referenced to find the virtual address.Creating a Mapping
Thekmapfunction must be used to create a mapping by means of apagepointer.^24 It is only a front end
to establish whether the desired page really is in highmem. If not, the address yielded bypage_address
is returned as the result. Otherwise, the kernel delegates work tokmap_high, which is defined as follows:mm/highmem.c
void fastcall *kmap_high(struct page *page)
{
unsigned long vaddr;vaddr = (unsigned long)page_address(page);
if (!vaddr)
vaddr = map_new_virtual(page);
pkmap_count[PKMAP_NR(vaddr)]++;
return (void*) vaddr;
}(^24) This function resides not only in arch/x86/mm/highmem_32.cbut also in include/asm-ppc/highmem.hand
include/asm-sparc/highmem.hwith practically the same definition.