Smaller Tables
- Page tables are too big.
- 32GB address space with 4KB pages are about 4MB per process.
- Run
ps auxw | wc -lon a unix machine and see how many processes are running.
-
How can we reduce the size of page tables?
- Bigger pages
- What happens to the page table size if we increase the page size to 16KB?
- It reduces to 25% of the original size. Not enough.
- Combining paging and segmentation.
- How would this work exactly? What would be the benefit?
- Think about how the current, single page table works:
- One register that points at the base of the page table.
- Location of page table entry is
base + entry_size * virtual_page_number
- Suppose the page table had four “segments”, each with its own base register.
- What would be the advantage?
- Each segment’s page table would need only be as large as necessary — no entries for “top” of the segment if it’s not in use.
- Top two bits of virtual address would identify the segment, then the next bits identify the virtual page within the segment.
- Advantage: Less unused space in the page table.
- What are the disadvantages?
- We still have similar fragmentation issues (e.g., may still need to move segment should it need to grow)
- Notice that it also doesn’t remove all unused page table space: We can still have wasted space if the segment is not densely packed.
- Notice the main issue: We want to avoid storing page table entries for pages that aren’t used — especially when there is a large block of unused entries.
- Also notice that fixed-sized pages provided a partial solution: We didn’t need to allocate physical memory for unused areas of the virtual address space.
- What would be the analogous solution to avoid storing large unused regions of the page table?
Multi-level page tables
- What if we turned the linear page table into a tree?
- We could simply skip unused branches.
- Draw a tree of depth 3 or 4 and erase several branches at different levels.
- We’ll start with just two levels:
- Chop the page table up into page-sized (i.e., 4KB) units.
- If every virtual page in that page-sized unit is unused, then don’t allocate that unit space in memory.
- Call the top-level a page directory.
- This either points to a page table entry, or is marked as not valid.
- Original divide:
20-12. New (one example)10-10-12 - Figure 20.3: https://pages.cs.wisc.edu/~remzi/OSTEP/vm-smalltables.pdf
- Advantage: Much smaller page table.
- What are the disadvantages?
- Two memory reads per TLB miss instead of one.
- More complexity in general.
- This is an example of the time-space tradeoff.
- What are some other examples?
- Building faster adders in CIS 351
- Cache size (more cache takes up space but reduces AMAT).
- Some algorithms make this tradeoff (e.g., dynamic programming)
- If we want all entities to fit in one physical frame, we may need additional levels.
- Remember: We only need deal with this complexity when there is a TLB miss.
Others
- Inverted page tables: One entry per frame
- Why is this good?
- In some sense, its optimal: It’s the fewest entries you can have (assuming you keep your RAM fully utilized)
- What are the challenges?
- Fining the entry for your virtual page.
- Any ideas?
- A hash table.
- The PowerPC used this.
- Why is this good?
- Swap page Tables to disk (almost like typical pages)