lec 7aoperating systems1 operating systems lecture 7a: linux memory manager william m. mongan

5
Lec 7a Operating Systems 1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan

Upload: branden-gilmore

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan

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

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

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

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

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)