Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1426675 > unrolled thread

[PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2016-06-20 17:10 +0200
Last post2016-06-21 15:30 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles Paolo Bonzini <pbonzini@redhat.com> - 2016-06-20 17:10 +0200
    [PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers Paolo Bonzini <pbonzini@redhat.com> - 2016-06-20 17:10 +0200
      Re: [PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers Rik van Riel <riel@redhat.com> - 2016-06-20 22:30 +0200
    Re: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls  by 150 clock cycles Paolo Bonzini <pbonzini@redhat.com> - 2016-06-21 15:30 +0200
    Re: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls  by 150 clock cycles Christian Borntraeger <borntraeger@de.ibm.com> - 2016-06-21 15:30 +0200

#1426675 — [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-06-20 17:10 +0200
Subject[PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles
Message-ID<rM8ZQ-1ph-5@gated-at.bofh.it>
The first patches are the two optimizations I posted on May 30th
for the system call entry/exit code.  The only change is in the
function names, which use the user_{enter,exit}_irqoff favored
by Andy and Ingo.  The first patch matches what commit d0e536d8939
("context_tracking: avoid irq_save/irq_restore on guest entry and exit",
2015-10-28) did for guest entry and exit.  The second simply adds
an inline annotation; the compiler doesn't figure it out because the
function is not static.

The second two patches move guest_{enter,exit} to the same naming
convention, removing the KVM wrappers kvm_guest_{enter,exit} and
__kvm_guest_{enter,exit} in the process.  I would like these two to
go through the KVM tree because I have other optimizations for 4.8
on top of these patches.

Thanks,

Paolo

Paolo Bonzini (4):
  x86/entry: Avoid interrupt flag save and restore
  x86/entry: Inline enter_from_user_mode
  context_tracking: move rcu_virt_note_context_switch out of kvm_host.h
  KVM: remove kvm_guest_enter/exit wrappers

 arch/arm/kvm/arm.c               |  8 +++---
 arch/mips/kvm/mips.c             |  4 +--
 arch/powerpc/kvm/book3s_hv.c     |  4 +--
 arch/powerpc/kvm/book3s_pr.c     |  4 +--
 arch/powerpc/kvm/booke.c         |  4 +--
 arch/powerpc/kvm/powerpc.c       |  2 +-
 arch/s390/kvm/kvm-s390.c         |  4 +--
 arch/x86/entry/common.c          |  6 ++---
 arch/x86/kvm/x86.c               |  4 +--
 include/linux/context_tracking.h | 53 +++++++++++++++++++++++++++++++++++++---
 include/linux/kvm_host.h         | 39 -----------------------------
 11 files changed, 69 insertions(+), 63 deletions(-)

-- 
1.8.3.1

[toc] | [next] | [standalone]


#1426681 — [PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-06-20 17:10 +0200
Subject[PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers
Message-ID<rM8ZR-1ph-39@gated-at.bofh.it>
In reply to#1426675
Use the functions from context_tracking.h directly.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/arm/kvm/arm.c           |  8 ++++----
 arch/mips/kvm/mips.c         |  4 ++--
 arch/powerpc/kvm/book3s_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_pr.c |  4 ++--
 arch/powerpc/kvm/booke.c     |  4 ++--
 arch/powerpc/kvm/powerpc.c   |  2 +-
 arch/s390/kvm/kvm-s390.c     |  4 ++--
 arch/x86/kvm/x86.c           |  4 ++--
 include/linux/kvm_host.h     | 22 ----------------------
 9 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 893941ec98dc..96b473c745a6 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -615,7 +615,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 		 * Enter the guest
 		 */
 		trace_kvm_entry(*vcpu_pc(vcpu));
-		__kvm_guest_enter();
+		guest_enter_irqoff();
 		vcpu->mode = IN_GUEST_MODE;
 
 		ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
@@ -641,14 +641,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 		local_irq_enable();
 
 		/*
-		 * We do local_irq_enable() before calling kvm_guest_exit() so
+		 * We do local_irq_enable() before calling guest_exit() so
 		 * that if a timer interrupt hits while running the guest we
 		 * account that tick as being spent in the guest.  We enable
-		 * preemption after calling kvm_guest_exit() so that if we get
+		 * preemption after calling guest_exit() so that if we get
 		 * preempted we make sure ticks after that is not counted as
 		 * guest time.
 		 */
-		kvm_guest_exit();
+		guest_exit();
 		trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
 
 		/*
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index dc052fb5c7a2..7b3f438802db 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -399,7 +399,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	kvm_mips_deliver_interrupts(vcpu,
 				    kvm_read_c0_guest_cause(vcpu->arch.cop0));
 
-	__kvm_guest_enter();
+	guest_enter_irqoff();
 
 	/* Disable hardware page table walking while in guest */
 	htw_stop();
@@ -409,7 +409,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	/* Re-enable HTW before enabling interrupts */
 	htw_start();
 
-	__kvm_guest_exit();
+	guest_exit_irqoff();
 	local_irq_enable();
 
 	if (vcpu->sigset_active)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index e20beae5ca7a..6b2859c12ae8 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2522,7 +2522,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
 		list_for_each_entry(pvc, &core_info.vcs[sub], preempt_list)
 			spin_unlock(&pvc->lock);
 
-	kvm_guest_enter();
+	guest_enter();
 
 	srcu_idx = srcu_read_lock(&vc->kvm->srcu);
 
@@ -2570,7 +2570,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
 
 	/* make sure updates to secondary vcpu structs are visible now */
 	smp_mb();
-	kvm_guest_exit();
+	guest_exit();
 
 	for (sub = 0; sub < core_info.n_subcores; ++sub)
 		list_for_each_entry_safe(pvc, vcnext, &core_info.vcs[sub],
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 8e4f64f0b774..6a66c5ff0827 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -914,7 +914,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	/* We get here with MSR.EE=1 */
 
 	trace_kvm_exit(exit_nr, vcpu);
-	kvm_guest_exit();
+	guest_exit();
 
 	switch (exit_nr) {
 	case BOOK3S_INTERRUPT_INST_STORAGE:
@@ -1531,7 +1531,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 
 	kvmppc_clear_debug(vcpu);
 
-	/* No need for kvm_guest_exit. It's done in handle_exit.
+	/* No need for guest_exit. It's done in handle_exit.
 	   We also get here with interrupts enabled. */
 
 	/* Make sure we save the guest FPU/Altivec/VSX state */
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 4afae695899a..02b4672f7347 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -776,7 +776,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 
 	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
 
-	/* No need for kvm_guest_exit. It's done in handle_exit.
+	/* No need for guest_exit. It's done in handle_exit.
 	   We also get here with interrupts enabled. */
 
 	/* Switch back to user space debug context */
@@ -1012,7 +1012,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	}
 
 	trace_kvm_exit(exit_nr, vcpu);
-	__kvm_guest_exit();
+	guest_exit_irqoff();
 
 	local_irq_enable();
 
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 02416fea7653..1ac036e45ed4 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -119,7 +119,7 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
 			continue;
 		}
 
-		__kvm_guest_enter();
+		guest_enter_irqoff();
 		return 1;
 	}
 
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 6d8ec3ac9dd8..6d054561f3a6 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2361,14 +2361,14 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
 		 * guest_enter and guest_exit should be no uaccess.
 		 */
 		local_irq_disable();
-		__kvm_guest_enter();
+		guest_enter_irqoff();
 		__disable_cpu_timer_accounting(vcpu);
 		local_irq_enable();
 		exit_reason = sie64a(vcpu->arch.sie_block,
 				     vcpu->run->s.regs.gprs);
 		local_irq_disable();
 		__enable_cpu_timer_accounting(vcpu);
-		__kvm_guest_exit();
+		guest_exit_irqoff();
 		local_irq_enable();
 		vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 902d9da12392..12d4f1fb568c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6636,7 +6636,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 
 	trace_kvm_entry(vcpu->vcpu_id);
 	wait_lapic_expire(vcpu);
-	__kvm_guest_enter();
+	guest_enter_irqoff();
 
 	if (unlikely(vcpu->arch.switch_db_regs)) {
 		set_debugreg(0, 7);
@@ -6695,7 +6695,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	 */
 	barrier();
 
-	kvm_guest_exit();
+	guest_exit();
 
 	preempt_enable();
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 30c9224545b1..6fe786901df1 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -867,28 +867,6 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm,
 }
 #endif
 
-/* must be called with irqs disabled */
-static inline void __kvm_guest_enter(void)
-{
-	guest_enter_irqoff();
-}
-
-/* must be called with irqs disabled */
-static inline void __kvm_guest_exit(void)
-{
-	guest_exit_irqoff();
-}
-
-static inline void kvm_guest_enter(void)
-{
-	guest_enter();
-}
-
-static inline void kvm_guest_exit(void)
-{
-	guest_exit();
-}
-
 /*
  * search_memslots() and __gfn_to_memslot() are here because they are
  * used in non-modular code in arch/powerpc/kvm/book3s_hv_rm_mmu.c.
-- 
1.8.3.1

[toc] | [prev] | [next] | [standalone]


#1427020 — Re: [PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers

FromRik van Riel <riel@redhat.com>
Date2016-06-20 22:30 +0200
SubjectRe: [PATCH 4/2] KVM: remove kvm_guest_enter/exit wrappers
Message-ID<rMdZv-4vT-7@gated-at.bofh.it>
In reply to#1426681

[Multipart message — attachments visible in raw view] — view raw

On Mon, 2016-06-20 at 16:58 +0200, Paolo Bonzini wrote:
> Use the functions from context_tracking.h directly.
> 
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> 
Reviewed-by: Rik van Riel <riel@redhat.com>

-- 
All Rights Reversed.

[toc] | [prev] | [next] | [standalone]


#1427752 — Re: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-06-21 15:30 +0200
SubjectRe: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles
Message-ID<rMtUC-6nL-35@gated-at.bofh.it>
In reply to#1426675

On 21/06/2016 15:24, Christian Borntraeger wrote:
> Series looks sane and does work on s390.
> It has a minor conflict with my vsie pull request (so either add vsie.c
> to this patch set or fixup my pull request in the merge commit to replace
> kvm_guest_exit/enter with the new functions.

It should not be an issue if I take the last two patches as proposed.

Paolo

[toc] | [prev] | [next] | [standalone]


#1427755 — Re: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles

FromChristian Borntraeger <borntraeger@de.ibm.com>
Date2016-06-21 15:30 +0200
SubjectRe: [PATCH v2 0/2] x86/entry: speed up context-tracking system calls by 150 clock cycles
Message-ID<rMtUC-6nL-37@gated-at.bofh.it>
In reply to#1426675
On 06/20/2016 04:58 PM, Paolo Bonzini wrote:
> The first patches are the two optimizations I posted on May 30th
> for the system call entry/exit code.  The only change is in the
> function names, which use the user_{enter,exit}_irqoff favored
> by Andy and Ingo.  The first patch matches what commit d0e536d8939
> ("context_tracking: avoid irq_save/irq_restore on guest entry and exit",
> 2015-10-28) did for guest entry and exit.  The second simply adds
> an inline annotation; the compiler doesn't figure it out because the
> function is not static.
> 
> The second two patches move guest_{enter,exit} to the same naming
> convention, removing the KVM wrappers kvm_guest_{enter,exit} and
> __kvm_guest_{enter,exit} in the process.  I would like these two to
> go through the KVM tree because I have other optimizations for 4.8
> on top of these patches.
> 
> Thanks,
> 
> Paolo
> 
> Paolo Bonzini (4):
>   x86/entry: Avoid interrupt flag save and restore
>   x86/entry: Inline enter_from_user_mode
>   context_tracking: move rcu_virt_note_context_switch out of kvm_host.h
>   KVM: remove kvm_guest_enter/exit wrappers
> 
>  arch/arm/kvm/arm.c               |  8 +++---
>  arch/mips/kvm/mips.c             |  4 +--
>  arch/powerpc/kvm/book3s_hv.c     |  4 +--
>  arch/powerpc/kvm/book3s_pr.c     |  4 +--
>  arch/powerpc/kvm/booke.c         |  4 +--
>  arch/powerpc/kvm/powerpc.c       |  2 +-
>  arch/s390/kvm/kvm-s390.c         |  4 +--
>  arch/x86/entry/common.c          |  6 ++---
>  arch/x86/kvm/x86.c               |  4 +--
>  include/linux/context_tracking.h | 53 +++++++++++++++++++++++++++++++++++++---
>  include/linux/kvm_host.h         | 39 -----------------------------
>  11 files changed, 69 insertions(+), 63 deletions(-)
> 
Series looks sane and does work on s390.
It has a minor conflict with my vsie pull request (so either add vsie.c
to this patch set or fixup my pull request in the merge commit to replace
kvm_guest_exit/enter with the new functions.

Christian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web