page结构体

page的定义

223 struct page {                                                                   
224         page_flags_t flags;             /* Atomic flags, some possibly          
225                                          * updated asynchronously */            
226         atomic_t _count;                /* Usage count, see below. */           
227         atomic_t _mapcount;             /* Count of ptes mapped in mms,         
228                                          * to show when page is mapped          
229                                          * & limit reverse map searches.        
230                                          */                                     
231         unsigned long private;          /* Mapping-private opaque data:         
232                                          * usually used for buffer_heads        
233                                          * if PagePrivate set; used for         
234                                          * swp_entry_t if PageSwapCache         
235                                          * When page is free, this indicates    
236                                          * order in the buddy system.           
237                                          */                                     
238         struct address_space *mapping;  /* If low bit clear, points to          
239                                          * inode address_space, or NULL.        
240                                          * If page mapped as anonymous          
241                                          * memory, low bit is set, and          
242                                          * it points to anon_vma object:        
243                                          * see PAGE_MAPPING_ANON below.         
244                                          */                                     
245         pgoff_t index;                  /* Our offset within mapping. */        
246         struct list_head lru;           /* Pageout list, eg. active_list        
247                                          * protected by zone->lru_lock !        
248                                          */                                     
249         /*                                                                      
250          * On machines where all RAM is mapped into kernel address space,       
251          * we can simply calculate the virtual address. On machines with        
252          * highmem some memory is mapped into kernel virtual memory             
253          * dynamically, so we need a place to store that address.               
254          * Note that this field could be 16 bits on x86 ... ;)                  
255          *                                                                      
256          * Architectures with slow multiplication can define                    
257          * WANT_PAGE_VIRTUAL in asm/page.h                                      
258          */                                                                     
259 #if defined(WANT_PAGE_VIRTUAL)                                                  
260         void *virtual;                  /* Kernel virtual address (NULL if                                                                                                                                    
261                                            not kmapped, ie. highmem) */         
262 #endif /* WANT_PAGE_VIRTUAL */                                                  
263 };                          

flags的类型

在文件include/linux/page-flags.h中:

 54 #define PG_locked                0      /* Page is locked. Don't touch. */      
 55 #define PG_error                 1                                              
 56 #define PG_referenced            2                                              
 57 #define PG_uptodate              3                                              
 58                                                                                 
 59 #define PG_dirty                 4                                              
 60 #define PG_lru                   5                                              
 61 #define PG_active                6                                              
 62 #define PG_slab                  7      /* slab debug (Suparna wants this) */   
 63                                                                                 
 64 #define PG_highmem               8                                              
 65 #define PG_checked               9      /* kill me in 2.5.<early>. */           
 66 #define PG_arch_1               10                                              
 67 #define PG_reserved             11                                              
 68                                                                                 
 69 #define PG_private              12      /* Has something at ->private */                                                                                                                                      
 70 #define PG_writeback            13      /* Page is under writeback */           
 71 #define PG_nosave               14      /* Used for system suspend/resume */    
 72 #define PG_compound             15      /* Part of a compound page */           
 73                                                                                 
 74 #define PG_swapcache            16      /* Swap page: swp_entry_t in private */ 
 75 #define PG_mappedtodisk         17      /* Has blocks allocated on-disk */      
 76 #define PG_reclaim              18      /* To be reclaimed asap */              
 77 #define PG_nosave_free          19      /* Free, should not be written */

__count成员

_count表示内核中引用该页面的次数。
在memmap_init_zone函数把set_page_count(page,0)把pagecount设置为-1,然后在free_all_bootmem_core调用set_page_refs(page, 0);在set_page_refs中set_page_count(page,1)把pagecount设置为0,这样初始化buddy的页的pagecount为0。
__count=0: 表示页是空闲的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值