summaryrefslogtreecommitdiff
path: root/virt
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2011-01-13 15:47:20 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 17:32:48 -0800
commit22e5c47ee238abe636655c3862ed28d6eb084ad4 (patch)
tree4a4e7d330cbef6c99a8914de482eb0e8daba2485 /virt
parent29ad768cfc08611a4c1070d0f13f82eeea2bac7b (diff)
downloadlinux-3.10-22e5c47ee238abe636655c3862ed28d6eb084ad4.tar.gz
linux-3.10-22e5c47ee238abe636655c3862ed28d6eb084ad4.tar.bz2
linux-3.10-22e5c47ee238abe636655c3862ed28d6eb084ad4.zip
thp: add compound_trans_head() helper
Cleanup some code with common compound_trans_head helper. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <jweiner@redhat.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Avi Kivity <avi@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4286d476651..f29abeb6a91 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -104,34 +104,24 @@ static pfn_t fault_pfn;
inline int kvm_is_mmio_pfn(pfn_t pfn)
{
if (pfn_valid(pfn)) {
- struct page *head;
+ int reserved;
struct page *tail = pfn_to_page(pfn);
- head = compound_head(tail);
+ struct page *head = compound_trans_head(tail);
+ reserved = PageReserved(head);
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.
+ * "head" is not a dangling pointer
+ * (compound_trans_head takes care of that)
+ * 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 check PageTail before returning
+ * what we just read.
*/
- 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;
- }
+ smp_rmb();
+ if (PageTail(tail))
+ return reserved;
}
return PageReserved(tail);
}