Skip to contentSkip to conversation

KVM: Discard unnecessary kvm_mmu_flush_tlb() in kvm_mmu_load()

PATCH Applied Sheng Yang 3 participants 6 messages Jul 9, 2009 – Jul 15, 2009

Subsystems (3)
lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 KVM: Discard unnecessary kvm_mmu_flush_tlb() in kvm_mmu_load()

set_cr3() should already cover the TLB flushing.

---
 arch/x86/kvm/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +1 -1
index 231d880..501c11e 100644
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
 	spin_unlock(&vcpu->kvm->mmu_lock);
 	if (r)
 		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
 	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
 out:
 	return r;
 }
Signature · 1 line
1.5.4.5
author
#1 lore raw
Quoted 2 lines · On Thursday 09 July 2009 17:00:42 Sheng Yang wrote:

set_cr3() should already cover the TLB flushing.

Comments?

Signature · 2 lines
regards
Yang, Sheng
Quoted 19 lines
---
 arch/x86/kvm/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +1 -1
index 231d880..501c11e 100644
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
 	spin_unlock(&vcpu->kvm->mmu_lock);
 	if (r)
 		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
 	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
 out:
 	return r;
 }
#2 lore raw
Quoted 4 lines · Sheng Yang
Quoted 2 lines · On Thursday 09 July 2009 17:00:42 Sheng Yang wrote:

set_cr3() should already cover the TLB flushing.

Comments?

Looks good.

Quoted 25 lines
Signature · 3 lines
-- 
regards
Yang, Sheng
Quoted 19 lines
---
 arch/x86/kvm/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +1 -1
index 231d880..501c11e 100644
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
 	spin_unlock(&vcpu->kvm->mmu_lock);
 	if (r)
 		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
 	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
 out:
 	return r;
 }
#3 lore raw
In reply to Sheng Yang
Quoted 13 lines · Sheng Yang

set_cr3() should already cover the TLB flushing.

---
  arch/x86/kvm/mmu.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +0 -0
index 231d880..501c11e 100644

arch/x86/kvm/mmu.c int kvm_mmu_load(struct kvm_vcpu *vcpu) · line 2356

Quoted 9 lines
arch/x86/kvm/mmu.c +1 -1
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
  	spin_unlock(&vcpu->kvm->mmu_lock);
  	if (r)
  		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
  	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
  out:
  	return r;
  }

Maybe we should drop the flushes in vmx/svm instead?

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#4 lore raw
Quoted 8 lines · On Monday 13 July 2009 20:23:58 Avi Kivity wrote:
Quoted 7 lines · Sheng Yang

set_cr3() should already cover the TLB flushing.

---
  arch/x86/kvm/mmu.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 16 lines
Quoted 5 lines
arch/x86/kvm/mmu.c +0 -0
index 231d880..501c11e 100644

arch/x86/kvm/mmu.c int kvm_mmu_load(struct kvm_vcpu *vcpu) · line 2356

Quoted 9 lines
arch/x86/kvm/mmu.c +1 -1
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
  	spin_unlock(&vcpu->kvm->mmu_lock);
  	if (r)
  		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
  	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
  out:
  	return r;
  }

Maybe we should drop the flushes in vmx/svm instead?

That's what I unsure about... mmu_load() with flushes sounds reasonable, set_cr3() with flushes sounds a little more reasonable to me because I think set_cr3() may shouldn't depends on caller to flush, which seems more direct.

Signature · 2 lines
regards
Yang, Sheng
#5 lore raw
In reply to Sheng Yang
Quoted 23 lines · Sheng Yang

set_cr3() should already cover the TLB flushing.

---
 arch/x86/kvm/mmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +1 -1
index 231d880..501c11e 100644
@@ -2349,8 +2349,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
 	spin_unlock(&vcpu->kvm->mmu_lock);
 	if (r)
 		goto out;
+	/* set_cr3() should ensure TLB has been flushed */
 	kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
-	kvm_mmu_flush_tlb(vcpu);
 out:
 	return r;
 }
Signature · 1 line
1.5.4.5

Applied, thanks.