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: 表示頁是空閑的