Transparent hugepages.
Huge zero page.
Kirill A. Shutemov
29 December 2012
Minsk, Belarus
Virtual to physical address translation
TLBVirtual address Physical addressTLB hit
Page tables walk
TLB missTLB write
TLB
• TLB is Fast:
– Three virtual to physical address translations every cycle (2 load, 1 store);
– TLB miss, STLB hit pe...
Page table walk, 4k pages
PGD Table PUD Table PMD Table PTE Table
213948
Page
0123063
offsetptepmdpudpgd
mm->pgd
pte
Virtu...
Huge pages
• Pros:
– Reduce TLB pressure:
• 1 TLB entry instead of 512 for every 2M;
• 4k and 2M pages have separate TLB e...
Page table walk, 2M pages
02130394863
offsetpmdpudpgd
mm->pgd
PGD Table PUD Table PMD Table Page
Virtual address
Hugetlbfs
• Cannot be swapped out;
• Need to be reserved on boot time;
• Requires to root access;
• Explicit application s...
Transparent Hugepages
• No special enabling is required;
• Graceful fallback to 4k pages;
• Hugepage can be splitted to 4k...
Zero page
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#define MB (1024*1024)
int main(int argc, char **arg...
0
Huge zero page
• Two designs have been evaluated:
• “physical” huge zero page;
• “virtual” huge zero page;
• Lockless re...
Questions?
Upcoming SlideShare
Loading in …5
×

Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page

530 views

Published on

Доклад на декабрьской линуксовке MLUG 2012

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
530
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page

  1. 1. Transparent hugepages. Huge zero page. Kirill A. Shutemov 29 December 2012 Minsk, Belarus
  2. 2. Virtual to physical address translation TLBVirtual address Physical addressTLB hit Page tables walk TLB missTLB write
  3. 3. TLB • TLB is Fast: – Three virtual to physical address translations every cycle (2 load, 1 store); – TLB miss, STLB hit penalty is 7 cycles; can usually be hidden by OOO execution; • Page table walk is Slow: – Hundreds cycles; – In the worst case a page table can be in swap;
  4. 4. Page table walk, 4k pages PGD Table PUD Table PMD Table PTE Table 213948 Page 0123063 offsetptepmdpudpgd mm->pgd pte Virtual address
  5. 5. Huge pages • Pros: – Reduce TLB pressure: • 1 TLB entry instead of 512 for every 2M; • 4k and 2M pages have separate TLB entires; – Faster page tables walk: 3 data access instead of 4; – Reduce cache pressure; • Cons: – Memory footprint; – clear_page/copy_page is not cache friendly;
  6. 6. Page table walk, 2M pages 02130394863 offsetpmdpudpgd mm->pgd PGD Table PUD Table PMD Table Page Virtual address
  7. 7. Hugetlbfs • Cannot be swapped out; • Need to be reserved on boot time; • Requires to root access; • Explicit application support is required; • No fallback to 4k pages;
  8. 8. Transparent Hugepages • No special enabling is required; • Graceful fallback to 4k pages; • Hugepage can be splitted to 4k pages at any time; • Hugepages can be swapped out as 4k pages; • MADV_HUGEPAGE and MADV_NOHUGEPAGE for tuning;
  9. 9. Zero page #include <assert.h> #include <stdlib.h> #include <unistd.h> #define MB (1024*1024) int main(int argc, char **argv) { char *p; int i; posix_memalign((void **)&p, 2 * MB, 200 * MB); for (i = 0; i < 200 * MB; i += 4096) assert(p[i] == 0); pause(); return 0; }
  10. 10. 0 Huge zero page • Two designs have been evaluated: • “physical” huge zero page; • “virtual” huge zero page; • Lockless refcounting: • free huge zero page in shrinker callback; • ~1% slowdown on 40 parallel read page faulting processes; • Merged in v3.8; • LWN: http://lwn.net/Articles/517465/
  11. 11. Questions?

×