kvm/e500: Do not keep shadow tlb array
Subsystems (2)
PATCH 1/3 kvm/e500: Do not keep shadow tlb array
Shadow tlb array costs a lot memory
and incurs potential coherence problem.
Remove it and we now translate to shadow mappings directly from guest TLB entries.
--- arch/powerpc/include/asm/kvm_e500.h | 8 +- arch/powerpc/kvm/e500_tlb.c | 277 +++++++++++++---------------------- 2 files changed, 106 insertions(+), 179 deletions(-)
arch/powerpc/include/asm/kvm_e500.h +7 -1
@@ -29,13 +29,19 @@ struct tlbe{u32 mas7; }; +struct kvmppc_e500_shadow_ref { +struct page *page; +u16 gtlb_index; +u16 pad; +}; +struct kvmppc_vcpu_e500 {/* Unmodified copy of the guest's TLB. */ struct tlbe *guest_tlb[E500_TLB_NUM ];/* TLB that's actually used when the guest is running. */ struct tlbe *shadow_tlb[E500_TLB_NUM ];/* Pages which are referenced in the shadow TLB. */ -struct page **shadow_pages[E500_TLB_NUM ]; +struct kvmppc_e500_shadow_ref *shadow_refs[E500_TLB_NUM ];unsigned int guest_tlb_size[E500_TLB_NUM ];unsigned int shadow_tlb_size[E500_TLB_NUM ];
arch/powerpc/kvm/e500_tlb.c +98 -176
452 lines not on this page · raw message
Signature · 1 line
1.5.4
Quoted 7 lines · Liu Yu
Shadow tlb array costs a lot memory
and incurs potential coherence problem.Remove it and we now translate to shadow mappings directly from guest TLB entries.
Signed-off-by Liu Yu <[email protected]>
Well, funny story... pretty much as soon as we removed the shadow TLB on 440, we put it back. But we use it differently now. Our experience on 440 was that it was a performance win to *also* keep a shadow TLB array, but use that *only* in the vcpu_put/vcpu_load() path instead of tlbia(). In other words, instead of just clearing all that guest TLB state you worked so hard to build up, preserve it across host context switches.
We don't use that array for anything other than host context switches. For normal exits (handled in kernel or handled in qemu) we take a less precise "shadowy" approach, where host and guest TLB entries can compete without KVM's knowledge, and we indiscriminately invalidate them.
(Yes, http://www.linux-kvm.org/page/PowerPC_Book_E_MMU is no longer completely accurate.)
I'm not sure what the coherence problems are that you allude to, but we never did SMP host support for 440.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 34 lines
-----Original Message-----
From: Hollis Blanchard [mailto:[email protected]]
Sent: Wednesday, April 29, 2009 3:34 AM
To: Liu Yu-B13201
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/3] kvm/e500: Do not keep shadow tlb arrayQuoted 7 lines · Liu Yu
Shadow tlb array costs a lot memory
and incurs potential coherence problem.Remove it and we now translate to shadow mappings directly from guest TLB entries.
Signed-off-by Liu Yu <[email protected]>Well, funny story... pretty much as soon as we removed the shadow TLB on
440, we put it back. But we use it differently now. Our experience on 440 was that it was a performance win to *also* keep a shadow TLB array,
but use that *only* in the vcpu_put/vcpu_load() path instead oftlbia().
In other words, instead of just clearing all that guest TLB state you worked so hard to build up, preserve it across host context switches.We don't use that array for anything other than host context switches. For normal exits (handled in kernel or handled in qemu) we take a less precise "shadowy" approach, where host and guest TLB entries can compete
without KVM's knowledge, and we indiscriminately invalidate them.
Quoted 6 lines
(Yes, http://www.linux-kvm.org/page/PowerPC_Book_E_MMU is no longer completely accurate.)
I'm not sure what the coherence problems are that you allude to, but we
never did SMP host support for 440.
It's not a SMP coherence problem.
But that after we apply shadow id trick, the shadow tlb entry may be expired due to the change of id mapping.
As we always update PID0, PID1 to the latest shadow id, write expired shadow entry back is useless and may incur other problem.
Moreover after applying shadow id trick, there is no tlbia() in the vcpu_load()/vcpu_put().
So I think it doesn't affect the performance of e500.