Skip to content

Commit c04bf72

Browse files
vdonnefortoupton
authored andcommitted
KVM: arm64: Do not transfer page refcount for THP adjustment
GUP affects a refcount common to all pages forming the THP. There is therefore no need to move the refcount from a tail to the head page. Under the hood it decrements and increments the same counter. Signed-off-by: Vincent Donnefort <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 909b583 commit c04bf72

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,28 +1295,8 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
12951295
if (sz < PMD_SIZE)
12961296
return PAGE_SIZE;
12971297

1298-
/*
1299-
* The address we faulted on is backed by a transparent huge
1300-
* page. However, because we map the compound huge page and
1301-
* not the individual tail page, we need to transfer the
1302-
* refcount to the head page. We have to be careful that the
1303-
* THP doesn't start to split while we are adjusting the
1304-
* refcounts.
1305-
*
1306-
* We are sure this doesn't happen, because mmu_invalidate_retry
1307-
* was successful and we are holding the mmu_lock, so if this
1308-
* THP is trying to split, it will be blocked in the mmu
1309-
* notifier before touching any of the pages, specifically
1310-
* before being able to call __split_huge_page_refcount().
1311-
*
1312-
* We can therefore safely transfer the refcount from PG_tail
1313-
* to PG_head and switch the pfn from a tail page to the head
1314-
* page accordingly.
1315-
*/
13161298
*ipap &= PMD_MASK;
1317-
kvm_release_pfn_clean(pfn);
13181299
pfn &= ~(PTRS_PER_PMD - 1);
1319-
get_page(pfn_to_page(pfn));
13201300
*pfnp = pfn;
13211301

13221302
return PMD_SIZE;

0 commit comments

Comments
 (0)