Refresh TLB only when switch vcpu for powerpc
Subsystems (2)
PATCH 1/1 Refresh TLB only when switch vcpu for powerpc
Some work such as TLB put/load on E500 is not necessary at every process switch, which may take place frequently when host workload is heavy.
This patch add a refresh interface for powerpc. These kind of work can use it to refresh at vcpu switch.
--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/e500.c | 7 +++++-- arch/powerpc/kvm/e500_tlb.c | 10 ++++------ arch/powerpc/kvm/e500_tlb.h | 3 +-- arch/powerpc/kvm/powerpc.c | 9 +++++++++ 5 files changed, 20 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +1 -0
@@ -76,6 +76,7 @@ extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,extern void kvmppc_core_vcpu_load (struct kvm_vcpu *vcpu,int cpu);extern void kvmppc_core_vcpu_put (struct kvm_vcpu *vcpu); +extern void kvmppc_core_vcpu_refresh (struct kvm_vcpu *vcpu,int cpu);extern void kvmppc_core_load_guest_debugstate (struct kvm_vcpu *vcpu);extern void kvmppc_core_load_host_debugstate (struct kvm_vcpu *vcpu);
arch/powerpc/kvm/e500.c +5 -2
@@ -34,12 +34,15 @@ void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu)void kvmppc_core_vcpu_load (struct kvm_vcpu *vcpu,int cpu) { -kvmppc_e500_tlb_load (vcpu, cpu); }void kvmppc_core_vcpu_put (struct kvm_vcpu *vcpu) { -kvmppc_e500_tlb_put (vcpu); +} + +void kvmppc_core_vcpu_refresh (struct kvm_vcpu *vcpu,int cpu) +{ +kvmppc_e500_tlb_refresh (vcpu, cpu); }int kvmppc_core_check_processor_compat (void )
arch/powerpc/kvm/e500_tlb.c +4 -6
@@ -129,11 +129,14 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,local_irq_enable (); } -void kvmppc_e500_tlb_load (struct kvm_vcpu *vcpu,int cpu) +void kvmppc_e500_tlb_refresh (struct kvm_vcpu *vcpu,int cpu) {struct kvmppc_vcpu_e500 *vcpu_e500 =to_e500 (vcpu);int i;unsigned register mas0; + +_tlbia (); +/* Mark every guest entry in the shadow TLB entry modified, so that they * will all be reloaded on the next vcpu run (instead of being * demand-faulted). */
@@ -152,11 +155,6 @@ void kvmppc_e500_tlb_load(struct kvm_vcpu *vcpu, int cpu)local_irq_enable (); } -void kvmppc_e500_tlb_put (struct kvm_vcpu *vcpu) -{ -_tlbia (); -} -/* Search the guest TLB for a matching entry. */ static int e500_tlb_index (struct kvmppc_vcpu_e500 *vcpu_e500,gva_t eaddr,int tlbsel,unsigned int pid,int as)
arch/powerpc/kvm/e500_tlb.h +1 -2
@@ -48,8 +48,7 @@ extern int kvmppc_e500_emul_tlbre(struct kvm_vcpu *);extern int kvmppc_e500_emul_tlbivax (struct kvm_vcpu *,int ,int );extern int kvmppc_e500_emul_tlbsx (struct kvm_vcpu *,int );extern int kvmppc_e500_tlb_search (struct kvm_vcpu *,gva_t ,int ); -extern void kvmppc_e500_tlb_put (struct kvm_vcpu *); -extern void kvmppc_e500_tlb_load (struct kvm_vcpu *,int ); +extern void kvmppc_e500_tlb_refresh (struct kvm_vcpu *,int );extern int kvmppc_e500_tlb_init (struct kvmppc_vcpu_e500 *);extern void kvmppc_e500_tlb_uninit (struct kvmppc_vcpu_e500 *);extern void kvmppc_e500_tlb_setup (struct kvmppc_vcpu_e500 *);
arch/powerpc/kvm/powerpc.c +9 -0
@@ -30,6 +30,8 @@#include <asm/tlbflush.h> #include "timing.h" +static DEFINE_PER_CPU(struct kvm_vcpu *, last_vcpu) = NULL; +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) {return gfn;
@@ -215,6 +217,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)void kvm_arch_vcpu_uninit (struct kvm_vcpu *vcpu) {kvmppc_mmu_destroy (vcpu); +__get_cpu_var (last_vcpu) =NULL ; }void kvm_arch_vcpu_load (struct kvm_vcpu *vcpu,int cpu)
@@ -223,6 +226,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)kvmppc_core_load_guest_debugstate (vcpu);kvmppc_core_vcpu_load (vcpu, cpu); + +/* Refresh work can be done only when switch vcpu */ +if (__get_cpu_var (last_vcpu) != vcpu) { +kvmppc_core_vcpu_refresh (vcpu, cpu); +__get_cpu_var (last_vcpu) = vcpu; + } }void kvm_arch_vcpu_put (struct kvm_vcpu *vcpu)
Signature · 1 line
1.5.4
Not sure 44x needs it...
Quoted 150 lines
-----Original Message-----
From: Liu Yu-B13201
Sent: Monday, December 15, 2008 5:55 PM
To: [email protected]
Cc: Liu Yu-B13201
Subject: [PATCH] Refresh TLB only when switch vcpu for powerpcSome work such as TLB put/load on E500 is not necessary at every process switch,
which may take place frequently when host workload is heavy.This patch add a refresh interface for powerpc. These kind of work can use it to refresh at vcpu switch.
Signed-off-by Liu Yu <[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/e500.c | 7 +++++-- arch/powerpc/kvm/e500_tlb.c | 10 ++++------ arch/powerpc/kvm/e500_tlb.h | 3 +-- arch/powerpc/kvm/powerpc.c | 9 +++++++++ 5 files changed, 20 insertions(+), 10 deletions(-)arch/powerpc/include/asm/kvm_ppc.h +1
-0@@ -76,6 +76,7 @@ extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu, extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu);extern void kvmppc_core_vcpu_put (struct kvm_vcpu *vcpu); +extern void kvmppc_core_vcpu_refresh (struct kvm_vcpu *vcpu,int cpu);extern void kvmppc_core_load_guest_debugstate (struct kvm_vcpu *vcpu);extern void
kvmppc_core_load_host_debugstate(struct kvm_vcpu *vcpu);arch/powerpc/kvm/e500.c +5
-2@@ -34,12 +34,15 @@ void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu) void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu) { -kvmppc_e500_tlb_load (vcpu, cpu); }void kvmppc_core_vcpu_put (struct kvm_vcpu *vcpu) { -kvmppc_e500_tlb_put (vcpu); +} + +void kvmppc_core_vcpu_refresh (struct kvm_vcpu *vcpu,int cpu) +{ +kvmppc_e500_tlb_refresh (vcpu, cpu); }int
kvmppc_core_check_processor_compat(void)arch/powerpc/kvm/e500_tlb.c +4
-1@@ -129,11 +129,14 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,local_irq_enable (); } -void kvmppc_e500_tlb_load (struct kvm_vcpu *vcpu,int cpu) +void kvmppc_e500_tlb_refresh (struct kvm_vcpu *vcpu,int cpu) {struct kvmppc_vcpu_e500 *vcpu_e500 =to_e500 (vcpu);int i;unsigned register mas0; + +_tlbia (); +/* Mark every guest entry in the shadow TLB entry modified, so that they
arch/powerpc/kvm/e500_tlb.c +0
-5* will all be reloaded on the next vcpu run (instead of being * demand-faulted). */ @@ -152,11 +155,6 @@ void kvmppc_e500_tlb_load(struct kvm_vcpu *vcpu, int cpu)local_irq_enable (); } -void kvmppc_e500_tlb_put (struct kvm_vcpu *vcpu) -{ -_tlbia (); -} -/* Search the guest TLB for a matching entry. */ static int e500_tlb_index(struct kvmppc_vcpu_e500
*vcpu_e500,gva_teaddr,arch/powerpc/kvm/e500_tlb.c +0
-0int tlbsel, unsigned int pid, int as)arch/powerpc/kvm/e500_tlb.h +1
-2@@ -48,8 +48,7 @@ extern int kvmppc_e500_emul_tlbre(struct kvm_vcpu *);extern int kvmppc_e500_emul_tlbivax (struct kvm_vcpu *,int ,int );extern int kvmppc_e500_emul_tlbsx (struct kvm_vcpu *,int );extern int kvmppc_e500_tlb_search (struct kvm_vcpu *,gva_t ,int ); -extern void kvmppc_e500_tlb_put (struct kvm_vcpu *); -extern void kvmppc_e500_tlb_load (struct kvm_vcpu *,int ); +extern void kvmppc_e500_tlb_refresh (struct kvm_vcpu *,int );extern int kvmppc_e500_tlb_init (struct kvmppc_vcpu_e500 *);extern void kvmppc_e500_tlb_uninit (struct kvmppc_vcpu_e500 *);extern void
kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *);arch/powerpc/kvm/powerpc.c +9
-0@@ -30,6 +30,8 @@#include <asm/tlbflush.h> #include "timing.h" +static DEFINE_PER_CPU(struct kvm_vcpu *, last_vcpu) = NULL; +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) {return gfn;@@ -215,6 +217,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)void kvm_arch_vcpu_uninit (struct kvm_vcpu *vcpu) {kvmppc_mmu_destroy (vcpu); +__get_cpu_var (last_vcpu) =NULL ; }void kvm_arch_vcpu_load (struct kvm_vcpu *vcpu,int cpu)@@ -223,6 +226,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)kvmppc_core_load_guest_debugstate (vcpu);kvmppc_core_vcpu_load (vcpu, cpu); + +/* Refresh work can be done only when switch vcpu */ +if (__get_cpu_var (last_vcpu) != vcpu) { +kvmppc_core_vcpu_refresh (vcpu, cpu); +__get_cpu_var (last_vcpu) = vcpu; + } }void
kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)Signature · 1 line
1.5.4
Oops.
This patch may fail when a kvm process switch to another core and then switch back.
Quoted 23 lines
-----Original Message-----
From: Liu Yu-B13201
Sent: Monday, December 15, 2008 5:55 PM
To: [email protected]
Cc: Liu Yu-B13201
Subject: [PATCH] Refresh TLB only when switch vcpu for powerpcSome work such as TLB put/load on E500 is not necessary at every process switch,
which may take place frequently when host workload is heavy.This patch add a refresh interface for powerpc. These kind of work can use it to refresh at vcpu switch.
Signed-off-by Liu Yu <[email protected]>--- arch/powerpc/include/asm/kvm_ppc.h | 1 + arch/powerpc/kvm/e500.c | 7 +++++-- arch/powerpc/kvm/e500_tlb.c | 10 ++++------ arch/powerpc/kvm/e500_tlb.h | 3 +-- arch/powerpc/kvm/powerpc.c | 9 +++++++++ 5 files changed, 20 insertions(+), 10 deletions(-)