thp: kvm mmu transparent hugepage support

This should work for both hugetlbfs and transparent hugepages.

[[email protected]: bring forward PageTransCompound() addition for bisectability]
Signed-off-by: Andrea Arcangeli <[email protected]>
Cc: Avi Kivity <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Andrea Arcangeli 2011-01-13 15:46:48 -08:00 • committed by Linus Torvalds
commit 936a5fe6e6
4 changed files with 125 additions and 19 deletions

View file

@ -104,8 +104,36 @@ static pfn_t fault_pfn;
inline int kvm_is_mmio_pfn(pfn_t pfn)
{
if (pfn_valid(pfn)) {
struct page *page = compound_head(pfn_to_page(pfn));
return PageReserved(page);
struct page *head;
struct page *tail = pfn_to_page(pfn);
head = compound_head(tail);
if (head != tail) {
smp_rmb();
/*
* head may be a dangling pointer.
* __split_huge_page_refcount clears PageTail
* before overwriting first_page, so if
* PageTail is still there it means the head
* pointer isn't dangling.
*/
if (PageTail(tail)) {
/*
* the "head" is not a dangling
* pointer but the hugepage may have
* been splitted from under us (and we
* may not hold a reference count on
* the head page so it can be reused
* before we run PageReferenced), so
* we've to recheck PageTail before
* returning what we just read.
*/
int reserved = PageReserved(head);
smp_rmb();
if (PageTail(tail))
return reserved;
}
}
return PageReserved(tail);
}
return true;