本文共 1769 字,大约阅读时间需要 5 分钟。
每个物理页关联一个page描述符,这样通过软件形式维护物理内存:struct page { 第1个 unsigned long flags; 第2个 union { struct address_space *mapping; void *s_mem; atomic_t compound_mapcount; }; 第3个 union { pgoff_t index; void *freelist; }; union {第4个#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE) unsigned long counters;#else unsigned counters;#endif struct { union { atomic_t _mapcount; unsigned int active; struct { unsigned inuse:16; unsigned objects:15; unsigned frozen:1; }; int units; }; atomic_t _refcount; }; }; union {第5个 struct list_head lru; struct dev_pagemap *pgmap; struct { struct page *next;#ifdef CONFIG_64BIT int pages; int pobjects;#else short int pages; short int pobjects;#endif }; struct rcu_head rcu_head;第6个 struct {第7个 unsigned long compound_head; #ifdef CONFIG_64BIT unsigned int compound_dtor; unsigned int compound_order;#else unsigned short int compound_dtor; unsigned short int compound_order;#endif }; 第8个#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS struct { unsigned long __pad; pgtable_t pmd_huge_pte; };#endif }; union {第9个 unsigned long private;#if USE_SPLIT_PTE_PTLOCKS#if ALLOC_SPLIT_PTLOCKS spinlock_t *ptl;#else spinlock_t ptl;#endif#endif struct kmem_cache *slab_cache; }; 第10个#ifdef CONFIG_MEMCG struct mem_cgroup *mem_cgroup;#endif 第11个#if defined(WANT_PAGE_VIRTUAL) void *virtual;#endif 第12个#ifdef CONFIG_KMEMCHECK void *shadow;#endif 第13个 #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid;#endif}第一个成员flags给出了页相关标识,比如页状态啊。 第二个是一个联合体,其给出在一个页用于不同的目的时,不同成员标记不同目的。mapping用于当页被映射 地址空间时起作用;而s_mem是指,这个页被用于slab缓存了。而compound_mapcount是用于当多个页作为 一个整体看待时,compound_mapcount给出这些页被映射到页表结构的进程数目。
转载地址:http://dzhti.baihongyu.com/