50 likes | 73 Views
Operating Systems Lecture 7a: Linux Memory Manager. William M. Mongan. Linux Pages. Linux pages are defined as a struct_page in linux/mm.h typedef struct page { struct list_head list; struct address_space *mapping; unsigned long index; struct page *next_hash; atomic_t count;
E N D
Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan Operating Systems
Linux Pages • Linux pages are defined as a struct_page in linux/mm.h typedef struct page { struct list_head list; struct address_space *mapping; unsigned long index; struct page *next_hash; atomic_t count; unsigned long flags; struct list_head lru; unsigned char age; unsigned char zone; struct pte_chain * pte_chain; struct page **pprev_hash; struct buffer_head * buffers; #if defined(CONFIG_HIGHMEM) || defined(CONFIG_SPARC64) void *virtual; #endif /* CONFIG_HIGMEM || CONFIG_SPARC64 */ } mem_map_t;
Linux Pages • count:reference count • flags: bit field including dirty bit, etc. • See linux/page-flags.h • virtual: virtual address
Zones • ZONE_DMA • Allows hardware performing DMA to have memory addresses mapped where they need them • ZONE_NORMAL • ZONE_HIGHMEM • Dynamically mapped at addresses higher than what may be virtually addressed • struct zone in linux/mmzone.h
Kernel Page Allocation • linux/mm.h and mm/page_alloc.c • alloc_page (return the page structure), get_free_page (return logical address) • free_page(logical_address) • Or, linux/slab.h for continuous slab • kmalloc(size, flag) and kfree(ptr) Or, linux/vmalloc.hand mm/vmalloc.c for noncontinuous physical page allocation vmalloc(size)