lec 7aoperating systems1 operating systems lecture 7a: linux memory manager william m. mongan
TRANSCRIPT
![Page 1: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan](https://reader036.vdocuments.us/reader036/viewer/2022082613/5697bf9d1a28abf838c93e2e/html5/thumbnails/1.jpg)
Lec 7a Operating Systems 1
Operating Systems
Lecture 7a: Linux Memory Manager
William M. Mongan
![Page 2: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan](https://reader036.vdocuments.us/reader036/viewer/2022082613/5697bf9d1a28abf838c93e2e/html5/thumbnails/2.jpg)
Linux Pages
• Linux pages are defined as a struct_page in linux/mm.htypedef 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;
![Page 3: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan](https://reader036.vdocuments.us/reader036/viewer/2022082613/5697bf9d1a28abf838c93e2e/html5/thumbnails/3.jpg)
Linux Pages
• count:reference count• flags: bit field including dirty bit, etc.
– See linux/page-flags.h
• virtual: virtual address
![Page 4: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan](https://reader036.vdocuments.us/reader036/viewer/2022082613/5697bf9d1a28abf838c93e2e/html5/thumbnails/4.jpg)
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
![Page 5: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan](https://reader036.vdocuments.us/reader036/viewer/2022082613/5697bf9d1a28abf838c93e2e/html5/thumbnails/5.jpg)
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.h and mm/vmalloc.c for noncontinuous physical page allocation
vmalloc(size)