THP和mapcount之间的恩恩怨怨
A reference count tracks the number of users an object (such as a page in memory)
has, allowing the kernel to determine when the object is free and can be deleted.
There are actually two types of reference counts for a normal page.
The first, stored in the _count field of struct page, is the total number of
references held to the page.
The second, kept in _mapcount, is the number of page table entries referring to this page.
A page-table mapping is a reference, so every such reference counted in _mapcount
is also tracked in _count; the latter should thus always be greater than or equal
to the former. Situations where _count can exceed _mapcount include pages mapped
for DMA and pages mapped into the kernel's address space with a function like
get_user_pages(). Locking a page into memory with mlock() will also increase _count.
The relative value of these two counters is important; if _count equals _mapcount,
the page can be reclaimed by locating and removing all of the page table entries.
But if _count is greater than _mapcount, the page is "pinned" and cannot be
reclaimed until the extra references are removed.页表项的几种可能以及遇到的问题
第一个版本 -- 不成功,便成仁
第二个版本 -- 波粒二象性
第三个版本 -- 文件透明大页
后续变化
total_compound_mapcount() -> folio_total_mapcount()
remove total_mapcount()
Remove folio_total_mapcount()
Last updated