For configuration see this article, my sytemd unit and transparent huge pages doc
Memory mapping with mmap
private/shared | file/anon | Huge allowed | Description |
---|---|---|---|
private | anon | OK | forked process will have the mmap region but will NOT see writes from parent |
private | memfd | OK | same as above |
private | file | NO | write to memory will NOT be persisted to the file |
shared | anon | OK | forked process will have the mmap region but will see writes from parent |
shared | file | NO | write to memory will eventually be persisted to file |
Huge page memory inspection
- This tool inspects page frames (and their flags) for each vma of a process.
# Stats on transparent huge pages
grep thp /proc/vmstat
# Stats on pre-allocated huge pages
grep -i huge /proc/meminfo
# Mounted hugetlbfs
mount | grep huge
# THP parameters
cat /sys/kernel/mm/transparent_hugepage/*/* /sys/kernel/mm/transparent_hugepage/*
FAQ
- Are all huge pages compound pages ?
- Looking at the page frame flags for the different types of allocation, it looks yes
- Can huge pages be swapped ?
- Looks like currently will be split back to small pages when written to swap storage.
- The reason is to minize cost of major page fault (copy whole huge page back from swap)
- Can file mapped memory use huge pages ? nope