Spring 2017 :: CSE 506
Page Frame Management
Nima Honarmand
Page Frame Management Nima Honarmand Spring 2017 :: CSE 506 Recap - - PowerPoint PPT Presentation
Spring 2017 :: CSE 506 Page Frame Management Nima Honarmand Spring 2017 :: CSE 506 Recap and Background Page tables: translate virtual addresses to physical addresses VM Areas (Linux): track what should be mapped in the virtual
Spring 2017 :: CSE 506
Nima Honarmand
Spring 2017 :: CSE 506
addresses
the virtual address space of a process
array of struct page objects
Spring 2017 :: CSE 506
physical memory?
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
Applications (Anonymous Memory) Files (Page Cache) Device DMA Buffers Kernel’s Dynamic Memory Allocator (kmalloc)
Physical Memory Pages
Spring 2017 :: CSE 506
whenever possible
number of pages
Spring 2017 :: CSE 506
requester; add the other one to the smaller list
is also free
buddy block of size 2B
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
the memory it requests
Spring 2017 :: CSE 506
Applications (Anonymous Memory) Files (Page Cache) Device DMA Buffers Kernel’s Dynamic Memory Allocator (kmalloc)
Physical Memory Pages
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
scanning the page descriptor table
1) Given a physical page descriptor, how do I find all of the mappings? Remember, pages can be shared. 2) What strategies should we follow when selecting a page to swap?
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
mappings?
the page + offset within the VMA
and the inode’s address space + offset within the file
Spring 2017 :: CSE 506
address space
a copy-on-write fork()
→Given a page, we need to know if it is shared, and find all VMAs and inode address space containing it
Spring 2017 :: CSE 506
(page-cache)
Spring 2017 :: CSE 506
anon_vma structure is also created
list
create a new VMA, link it on the anon_vma list
Spring 2017 :: CSE 506
Physical memory Process A Process B (forked) Virtual memory page descriptor vma vma anon_vma
Spring 2017 :: CSE 506
the page table to check
Spring 2017 :: CSE 506
its page descriptor to the inode’s address space
→ Easy to find the address space entry
anonymous mappings, no?
Spring 2017 :: CSE 506
→Problem: lots of entries on the list + many that might not overlap
Spring 2017 :: CSE 506
Tree to store all the VMAs mapping a file
Spring 2017 :: CSE 506
mapping it
to that range
linear address in the page table to invalidate
Spring 2017 :: CSE 506
Investigate and write a detailed report of the data structures and algorithms used for reverse mapping in Linux 4.19 (latest version as of the time of this writing)
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
Spring 2017 :: CSE 506
in a while
Spring 2017 :: CSE 506
memory is scarce
process can get enough memory to finish
process really needs
Spring 2017 :: CSE 506
farthest in the future
Spring 2017 :: CSE 506
hardware, you can assume the page is “cold”
Spring 2017 :: CSE 506
failing
processes until memory can be reclaimed
Spring 2017 :: CSE 506
without a lot of good science behind it
conditions