struct page { unsigned long flags; /* Atomic flags, some possibly * updated asynchronously */ atomic_t _count; /* Usage count, see below. */ union { atomic_t _mapcount; /* Count of ptes mapped in mms, * to show when page is mapped * & limit reverse map searches. */ struct { /* SLUB */ u16 inuse; u16 objects; }; }; union { struct { unsigned long private; /* Mapping-private opaque data: * usually used for buffer_heads * if PagePrivate set; used for * swp_entry_t if PageSwapCache; * indicates order in the buddy * system if PG_buddy is set. */ struct address_space *mapping; /* If low bit clear, points to * inode address_space, or NULL. * If page mapped as anonymous * memory, low bit is set, and * it points to anon_vma object: * see PAGE_MAPPING_ANON below. */ }; #if USE_SPLIT_PTLOCKS spinlock_t ptl; #endif struct kmem_cache *slab; /* SLUB: Pointer to slab */ struct page *first_page; /* Compound tail pages */ }; union { pgoff_t index; /* Our offset within mapping. */ void *freelist; /* SLUB: freelist req. slab lock */ }; struct list_head lru; /* Pageout list, eg. active_list * protected by zone->lru_lock ! */ /* * On machines where all RAM is mapped into kernel address space, * we can simply calculate the virtual address. On machines with * highmem some memory is mapped into kernel virtual memory * dynamically, so we need a place to store that address. * Note that this field could be 16 bits on x86 ... ;) * * Architectures with slow multiplication can define * WANT_PAGE_VIRTUAL in asm/page.h */ #if defined(WANT_PAGE_VIRTUAL) void *virtual; /* Kernel virtual address (NULL if not kmapped, ie. highmem) */ #endif /* WANT_PAGE_VIRTUAL */ #ifdef CONFIG_WANT_PAGE_DEBUG_FLAGS unsigned long debug_flags; /* Use atomic bitops on this */ #endif #ifdef CONFIG_KMEMCHECK /* * kmemcheck wants to track the status of each byte in a page; this * is a pointer to such a status block. NULL if not tracked. */ void *shadow; #endif }; /* * A region containing a mapping of a non-memory backed file under NOMMU * conditions. These are held in a global tree and are pinned by the VMAs that * map parts of them. */ struct vm_region { struct rb_node vm_rb; /* link in global region tree */ unsigned long vm_flags; /* VMA vm_flags */ unsigned long vm_start; /* start address of region */ unsigned long vm_end; /* region initialised to here */ unsigned long vm_top; /* region allocated to here */ unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */ struct file *vm_file; /* the backing file or NULL */ int vm_usage; /* region usage count (access under nommu_region_sem) */ bool vm_icache_flushed : 1; /* true if the icache has been flushed for * this region */ };
1 unsigned long flags
unsigned long flags //flags在page-flags.h文件夹中枚举 //paging_init()可设置PG_reserved做flags //mem_init()可设置含PG_reserved的flags清除 //#define PG_reserved 11;表示页保留,无法被__free_page()回收
2 atomic_t _count和atumic_t _mapcount
atomic_t _count; //页引用计数器 atomic_t _mapcount; //页映射计数器 //paging_init()可以将它们初始化为-1 //mem_init()可以将所有位码为0的页的_count设置为0 //page_count和page_mapcount可以统计其实用者个数 //_count+1为页使用者个数,_mapcount+1为页共享者个数 // _count为-1时不可被__free_page()释放 //_mapcount为0表示该页未被共享
3 unsigned long private
unsigned long private; //私有数据指针 //设置为PG_private,则private字段指向struct buffer_head //设置为PG_compound,则指向struct page //设置为PG_swapcache,则private为swp_entry_t的成员变量val
4 struct address_space *mapping
struct address_space *mapping; //该页所在地址空间描述结构指针 /*page->mapping == 0 属于交换高速缓存页 *page->mapping != 0 且第0位为1,为匿名页,指向struct anon_vma *page->mapping != 0 且第0位为0,指向struct address_space地址空间结构变量 */
5 pgoff_t index
pgoff_t index; //该页描述结构在地址空间radix树page_tree中的对象索引号即页号 //表示该页在vm_file中的便宜页数 //#define unsigned long pgoff_t
6 struct list_head lru
struct list_head lru; //最近、最久未使用struct slab结构指针变量 //设置PG_slab,则该页由slab分配器来管理,lru.next指向kmem_cache_t结构变量,lru.prev则指向struct slab结构
7 struct pagevec
struct pagevec { //页向量描述结构 unsigned long nr; //该页向量中的内存页数 unsigned long cold; //冷区标志,0表示热区,非0表示冷区 struct page *pages[PAGEVEC_SIZE]; //该也想两种的页描述结构指针数组(PAGEVEC_SIZE=14) };
8 struct page_address_map
struct page_address_map { //页地址映射 struct page *page; //页的描述结构 void *virtual; //页的虚拟地址 struct list_head list; //通过list字段链接到页表池全局链表page_address_pool中或page_address_htable[hash_ptr(page,PA_HASH_ORDER)].lh };
9 struct page_address_slot
static struct page_address_slot { struct list_head lh; /* List of page_address_maps */ spinlock_t lock; /* Protect this bucket's list */ } ____cacheline_aligned_in_smp page_address_htable[1<<PA_HASH_ORDER];