kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kvm: mmu: Use fast PF path for access tracking of huge pages when possible
@ 2021-11-04  0:33 Junaid Shahid
  2021-11-11 13:56 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Junaid Shahid @ 2021-11-04  0:33 UTC (permalink / raw)
  To: kvm, pbonzini; +Cc: jmattson, seanjc, bgardon

The fast page fault path bails out on write faults to huge pages in
order to accommodate dirty logging. This change adds a check to do that
only when dirty logging is actually enabled, so that access tracking for
huge pages can still use the fast path for write faults in the common
case.

Signed-off-by: Junaid Shahid <junaids@google.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
---
v2:
 - Removed a stale comment

 arch/x86/kvm/mmu/mmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 354d2ca92df4..04c00c34517e 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -3191,17 +3191,17 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
 			new_spte |= PT_WRITABLE_MASK;
 
 			/*
-			 * Do not fix write-permission on the large spte.  Since
-			 * we only dirty the first page into the dirty-bitmap in
+			 * Do not fix write-permission on the large spte when
+			 * dirty logging is enabled. Since we only dirty the
+			 * first page into the dirty-bitmap in
 			 * fast_pf_fix_direct_spte(), other pages are missed
 			 * if its slot has dirty logging enabled.
 			 *
 			 * Instead, we let the slow page fault path create a
 			 * normal spte to fix the access.
-			 *
-			 * See the comments in kvm_arch_commit_memory_region().
 			 */
-			if (sp->role.level > PG_LEVEL_4K)
+			if (sp->role.level > PG_LEVEL_4K &&
+			    kvm_slot_dirty_track_enabled(fault->slot))
 				break;
 		}
 
-- 
2.33.1.1089.g2158813163f-goog


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

* Re: [PATCH v2] kvm: mmu: Use fast PF path for access tracking of huge pages when possible
  2021-11-04  0:33 [PATCH v2] kvm: mmu: Use fast PF path for access tracking of huge pages when possible Junaid Shahid
@ 2021-11-11 13:56 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2021-11-11 13:56 UTC (permalink / raw)
  To: Junaid Shahid, kvm; +Cc: jmattson, seanjc, bgardon

On 11/4/21 01:33, Junaid Shahid wrote:
> The fast page fault path bails out on write faults to huge pages in
> order to accommodate dirty logging. This change adds a check to do that
> only when dirty logging is actually enabled, so that access tracking for
> huge pages can still use the fast path for write faults in the common
> case.
> 
> Signed-off-by: Junaid Shahid <junaids@google.com>
> Reviewed-by: Ben Gardon <bgardon@google.com>
> Reviewed-by: Sean Christopherson <seanjc@google.com>
> ---
> v2:
>   - Removed a stale comment
> 
>   arch/x86/kvm/mmu/mmu.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 354d2ca92df4..04c00c34517e 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -3191,17 +3191,17 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
>   			new_spte |= PT_WRITABLE_MASK;
>   
>   			/*
> -			 * Do not fix write-permission on the large spte.  Since
> -			 * we only dirty the first page into the dirty-bitmap in
> +			 * Do not fix write-permission on the large spte when
> +			 * dirty logging is enabled. Since we only dirty the
> +			 * first page into the dirty-bitmap in
>   			 * fast_pf_fix_direct_spte(), other pages are missed
>   			 * if its slot has dirty logging enabled.
>   			 *
>   			 * Instead, we let the slow page fault path create a
>   			 * normal spte to fix the access.
> -			 *
> -			 * See the comments in kvm_arch_commit_memory_region().
>   			 */
> -			if (sp->role.level > PG_LEVEL_4K)
> +			if (sp->role.level > PG_LEVEL_4K &&
> +			    kvm_slot_dirty_track_enabled(fault->slot))
>   				break;
>   		}
>   
> 

Queued, thanks.

Paolo


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

end of thread, other threads:[~2021-11-11 13:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  0:33 [PATCH v2] kvm: mmu: Use fast PF path for access tracking of huge pages when possible Junaid Shahid
2021-11-11 13:56 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).