All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging
@ 2018-12-12  4:16 Paul Mackerras
  2018-12-12  5:18 ` Suraj Jitindar Singh
  2018-12-12 23:29 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Mackerras @ 2018-12-12  4:16 UTC (permalink / raw)
  To: kvm-ppc

For radix guests, this makes KVM map guest memory as individual pages
when dirty page logging is enabled for the memslot corresponding to the
guest real address.  Having a separate partition-scoped PTE for each
system page mapped to the guest means that we have a separate dirty
bit for each page, thus making the reported dirty bitmap more accurate.
Without this, if part of guest memory is backed by transparent huge
pages, the dirty status is reported at a 2MB granularity rather than
a 64kB (or 4kB) granularity for that part, causing userspace to have
to transmit more data when migrating the guest.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index d68162e..87ad35e 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -683,6 +683,7 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
 	pte_t pte, *ptep;
 	unsigned int shift, level;
 	int ret;
+	bool large_enable;
 
 	/* used to check for invalidations in progress */
 	mmu_seq = kvm->mmu_notifier_seq;
@@ -732,12 +733,15 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
 	pte = *ptep;
 	local_irq_enable();
 
+	/* If we're logging dirty pages, always map single pages */
+	large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES);
+
 	/* Get pte level from shift/size */
-	if (shift = PUD_SHIFT &&
+	if (large_enable && shift = PUD_SHIFT &&
 	    (gpa & (PUD_SIZE - PAGE_SIZE)) =
 	    (hva & (PUD_SIZE - PAGE_SIZE))) {
 		level = 2;
-	} else if (shift = PMD_SHIFT &&
+	} else if (large_enable && shift = PMD_SHIFT &&
 		   (gpa & (PMD_SIZE - PAGE_SIZE)) =
 		   (hva & (PMD_SIZE - PAGE_SIZE))) {
 		level = 1;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging
  2018-12-12  4:16 [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging Paul Mackerras
@ 2018-12-12  5:18 ` Suraj Jitindar Singh
  2018-12-12 23:29 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Suraj Jitindar Singh @ 2018-12-12  5:18 UTC (permalink / raw)
  To: kvm-ppc

On Wed, 2018-12-12 at 15:16 +1100, Paul Mackerras wrote:
> For radix guests, this makes KVM map guest memory as individual pages
> when dirty page logging is enabled for the memslot corresponding to
> the
> guest real address.  Having a separate partition-scoped PTE for each
> system page mapped to the guest means that we have a separate dirty
> bit for each page, thus making the reported dirty bitmap more
> accurate.
> Without this, if part of guest memory is backed by transparent huge
> pages, the dirty status is reported at a 2MB granularity rather than
> a 64kB (or 4kB) granularity for that part, causing userspace to have
> to transmit more data when migrating the guest.

Reviewed-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>

> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> ---
>  arch/powerpc/kvm/book3s_64_mmu_radix.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index d68162e..87ad35e 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -683,6 +683,7 @@ int kvmppc_book3s_instantiate_page(struct
> kvm_vcpu *vcpu,
>  	pte_t pte, *ptep;
>  	unsigned int shift, level;
>  	int ret;
> +	bool large_enable;
>  
>  	/* used to check for invalidations in progress */
>  	mmu_seq = kvm->mmu_notifier_seq;
> @@ -732,12 +733,15 @@ int kvmppc_book3s_instantiate_page(struct
> kvm_vcpu *vcpu,
>  	pte = *ptep;
>  	local_irq_enable();
>  
> +	/* If we're logging dirty pages, always map single pages */
> +	large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES);
> +
>  	/* Get pte level from shift/size */
> -	if (shift = PUD_SHIFT &&
> +	if (large_enable && shift = PUD_SHIFT &&
>  	    (gpa & (PUD_SIZE - PAGE_SIZE)) =
>  	    (hva & (PUD_SIZE - PAGE_SIZE))) {
>  		level = 2;
> -	} else if (shift = PMD_SHIFT &&
> +	} else if (large_enable && shift = PMD_SHIFT &&
>  		   (gpa & (PMD_SIZE - PAGE_SIZE)) =
>  		   (hva & (PMD_SIZE - PAGE_SIZE))) {
>  		level = 1;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging
  2018-12-12  4:16 [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging Paul Mackerras
  2018-12-12  5:18 ` Suraj Jitindar Singh
@ 2018-12-12 23:29 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2018-12-12 23:29 UTC (permalink / raw)
  To: kvm-ppc

[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]

On Wed, Dec 12, 2018 at 03:16:17PM +1100, Paul Mackerras wrote:
> For radix guests, this makes KVM map guest memory as individual pages
> when dirty page logging is enabled for the memslot corresponding to the
> guest real address.  Having a separate partition-scoped PTE for each
> system page mapped to the guest means that we have a separate dirty
> bit for each page, thus making the reported dirty bitmap more accurate.
> Without this, if part of guest memory is backed by transparent huge
> pages, the dirty status is reported at a 2MB granularity rather than
> a 64kB (or 4kB) granularity for that part, causing userspace to have
> to transmit more data when migrating the guest.
> 
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  arch/powerpc/kvm/book3s_64_mmu_radix.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index d68162e..87ad35e 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -683,6 +683,7 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
>  	pte_t pte, *ptep;
>  	unsigned int shift, level;
>  	int ret;
> +	bool large_enable;
>  
>  	/* used to check for invalidations in progress */
>  	mmu_seq = kvm->mmu_notifier_seq;
> @@ -732,12 +733,15 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
>  	pte = *ptep;
>  	local_irq_enable();
>  
> +	/* If we're logging dirty pages, always map single pages */
> +	large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES);
> +
>  	/* Get pte level from shift/size */
> -	if (shift == PUD_SHIFT &&
> +	if (large_enable && shift == PUD_SHIFT &&
>  	    (gpa & (PUD_SIZE - PAGE_SIZE)) ==
>  	    (hva & (PUD_SIZE - PAGE_SIZE))) {
>  		level = 2;
> -	} else if (shift == PMD_SHIFT &&
> +	} else if (large_enable && shift == PMD_SHIFT &&
>  		   (gpa & (PMD_SIZE - PAGE_SIZE)) ==
>  		   (hva & (PMD_SIZE - PAGE_SIZE))) {
>  		level = 1;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-12 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12  4:16 [PATCH 2/4] KVM: PPC: Book3S HV: Map single pages when doing dirty page logging Paul Mackerras
2018-12-12  5:18 ` Suraj Jitindar Singh
2018-12-12 23:29 ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.