[PATCH 1/2] KVM MMU: cleanup/fix mmu audit code

2010-04-01 Thread Xiao Guangrong
This patch does: - 'sp' parameter in inspect_spte_fn() is not used, so remove it - fix 'kvm' and 'slots' is not defined in count_rmaps() - fix a bug in inspect_spte_has_rmap() Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 15 --- 1 files

[PATCH 2/2] KVM MMU: record reverse mapping for spte only if it's writable

2010-04-01 Thread Xiao Guangrong
The read only spte mapping can't hurt shadow page cache, so, no need to record it. Using bit9 to record whether the spte is re-mapped Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 17 +++-- arch/x86/kvm/mmu.h |1 + 2 files changed, 16

Re: [RFC] KVM MMU: thinking of shadow page cache

2010-04-01 Thread Xiao Guangrong
Avi Kivity wrote: We've considered this in the past, it makes sense. The big question is whether any guests actually map the same page table through PDEs with different permissions (mapping the same page table through multiple PDEs is very common, but always with the same

[PATCH 1/2] KVM MMU: remove unused field

2010-04-06 Thread Xiao Guangrong
kvm_mmu_page.oos_link is not used, so remove it Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |2 -- arch/x86/kvm/mmu.c |1 - 2 files changed, 0 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b

[PATCH 2/2] KVM MMU: remove unnecessary judgement

2010-04-06 Thread Xiao Guangrong
After is_rsvd_bits_set() checks, EFER.NXE must be enabled if NX bit is seted Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h

[PATCH 1/6] KVM MMU: remove unused struct

2010-04-12 Thread Xiao Guangrong
Remove 'struct kvm_unsync_walk' since it's not used now Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b44380b..a23ca75 100644 --- a/arch

[PATCH 2/6] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-12 Thread Xiao Guangrong
- calculate zapped page number properly in mmu_zap_unsync_children() - calculate freeed page number properly kvm_mmu_change_mmu_pages() - restart list walking if have children page zapped Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |7 --- 1 files

[PATCH 3/6] KVM MMU: optimize/cleanup for marking parent unsync

2010-04-12 Thread Xiao Guangrong
- 'vcpu' is not used while mark parent unsync, so remove it - if it has alread marked unsync, no need to walk it's parent Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 69 +-- 1 files changed, 23 insertions

[PATCH 4/6] KVM MMU: optimize for writing cr4

2010-04-12 Thread Xiao Guangrong
Usually, OS changes CR4.PGE bit to flush all global page, under this case, no need reset mmu and just flush tlb Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/x86.c |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b

[PATCH 5/6] KVM MMU: reduce kvm_mmu_page size

2010-04-12 Thread Xiao Guangrong
'multimapped' and 'unsync' in 'struct kvm_mmu_page' are just indication field, we can use flag bits instand of them Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |5 ++- arch/x86/kvm/mmu.c | 65

[PATCH 6/6] KVM MMU: optimize synchronization shadow pages

2010-04-12 Thread Xiao Guangrong
- chain all unsync shadow pages then we can fetch them quickly - flush local/remote tlb after all shadow page synced Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |1 + arch/x86/kvm/mmu.c | 82

Re: [PATCH 2/6] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: kvm-arch.n_free_mmu_pages = 0; @@ -1589,7 +1589,8 @@ static void mmu_unshadow(struct kvm *kvm, gfn_t gfn) !sp-role.invalid) { pgprintk(%s: zap %lx %x\n, __func__, gfn, sp-role.word); -

Re: [PATCH 3/6] KVM MMU: optimize/cleanup for marking parent unsync

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: On 04/12/2010 11:02 AM, Xiao Guangrong wrote: - 'vcpu' is not used while mark parent unsync, so remove it - if it has alread marked unsync, no need to walk it's parent Please separate these two changes. The optimization looks good. Perhaps it can be done even

Re: [PATCH 2/6] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-12 Thread Xiao Guangrong
Hi Avi, Avi Kivity wrote: hlist_for_each_entry_safe() is supposed to be be safe against removal of the element that is pointed to by the iteration cursor. If we destroyed the next point, hlist_for_each_entry_safe() is unsafe. List hlist_for_each_entry_safe()'s code: |#define

Re: [PATCH 4/6] KVM MMU: optimize for writing cr4

2010-04-12 Thread Xiao Guangrong
Hi Avi, Thanks for your comments. Avi Kivity wrote: Later we have: kvm_x86_ops-set_cr4(vcpu, cr4); vcpu-arch.cr4 = cr4; vcpu-arch.mmu.base_role.cr4_pge = (cr4 X86_CR4_PGE) !tdp_enabled; All of which depend on cr4. Oh, destroy_kvm_mmu() is not really

Re: [PATCH 5/6] KVM MMU: reduce kvm_mmu_page size

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: On 04/12/2010 11:05 AM, Xiao Guangrong wrote: 'multimapped' and 'unsync' in 'struct kvm_mmu_page' are just indication field, we can use flag bits instand of them @@ -202,9 +202,10 @@ struct kvm_mmu_page { * in this shadow page. */ DECLARE_BITMAP

Re: [PATCH 6/6] KVM MMU: optimize synchronization shadow pages

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: On 04/12/2010 11:06 AM, Xiao Guangrong wrote: - chain all unsync shadow pages then we can fetch them quickly - flush local/remote tlb after all shadow page synced Signed-off-by: Xiao Guangrongxiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |1

Re: [PATCH 2/6] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: On 04/12/2010 12:22 PM, Xiao Guangrong wrote: Hi Avi, Avi Kivity wrote: But kvm_mmu_zap_page() will only destroy sp == tpos == pos; n points at pos-next already, so it's safe. kvm_mmu_zap_page(sp) not only zaps sp but also zaps all sp's unsync children pages, if n

Re: [PATCH 3/6] KVM MMU: optimize/cleanup for marking parent unsync

2010-04-12 Thread Xiao Guangrong
Marcelo Tosatti wrote: Xiao, Did you actually see this codepath as being performance sensitive? Actually, i not run benchmarks to contrast the performance before this patch and after this patch. I'd prefer to not touch it. This patch avoids walk all parents and i think this overload

Re: [PATCH 4/6] KVM MMU: optimize for writing cr4

2010-04-12 Thread Xiao Guangrong
Avi Kivity wrote: See 6364a3918cb. It was reverted later due to a problem with the implementation. I'm not sure whether I want to fix the bug and restore that patch, or to drop it altogether and give the guest ownership of cr4.pge. See cr4_guest_owned_bits (currently only used on ept).

Re: [PATCH 3/6] KVM MMU: optimize/cleanup for marking parent unsync

2010-04-13 Thread Xiao Guangrong
Marcelo Tosatti wrote: I'd prefer to not touch it. This patch avoids walk all parents and i think this overload is really unnecessary. It has other tricks in this codepath but i not noticed? :-) My point is that there is no point in optimizing something unless its performance

[PATCH v2 1/5] KVM MMU: remove unused struct

2010-04-15 Thread Xiao Guangrong
Remove 'struct kvm_unsync_walk' since it's not used Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b44380b..a23ca75 100644 --- a/arch/x86

[PATCH v2 2/5] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-15 Thread Xiao Guangrong
- calculate zapped page number properly in mmu_zap_unsync_children() - calculate freeed page number properly kvm_mmu_change_mmu_pages() Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 12 1 files changed, 8 insertions(+), 4 deletions(-) diff

[PATCH v2 3/5] KVM MMU: cleanup for restart hlist walking

2010-04-15 Thread Xiao Guangrong
Quote from Avi: |Just change the assignment to a 'goto restart;' please, |I don't like playing with list_for_each internals. Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 15 ++- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git

[PATCH v2 4/5] KVM MMU: smaller reduce 'struct kvm_mmu_page' size

2010-04-15 Thread Xiao Guangrong
define 'multimapped' as 'bool' Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 0c49c88..cace232

[PATCH v2 5/5] KVM MMU: remove unused parameter in mmu_parent_walk()

2010-04-15 Thread Xiao Guangrong
'vcpu' is unused, remove it Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 24 +++- 1 files changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index a32c60c..2f8ae9e 100644 --- a/arch/x86/kvm

[PATCH v3 1/2] KVM MMU: fix kvm_mmu_zap_page() and its calling path

2010-04-16 Thread Xiao Guangrong
This patch fix: - calculate zapped page number properly in mmu_zap_unsync_children() - calculate freeed page number properly kvm_mmu_change_mmu_pages() - if zapped children page it shoud restart hlist walking Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c

[PATCH v3 2/2] KVM MMU: KVM MMU: cleanup for restart hlist walking

2010-04-16 Thread Xiao Guangrong
Quote from Avi: |Just change the assignment to a 'goto restart;' please, |I don't like playing with list_for_each internals. Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 15 ++- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git

[PATCH 0/10] KVM MMU: allow more shadow pages become asynchronous

2010-04-22 Thread Xiao Guangrong
In current code, shadow page can become asynchronous only if one shadow page for a gfn, this rule is too strict, in fact, we can let all last mapping page(i.e, it's the pte page) become unsync and sync them at invlpg or flush tlb time. Address this thinking, a gfn may have many shadow pages, for

[PATCH 1/10] KVM MMU: fix for calculating gpa in invlpg code

2010-04-22 Thread Xiao Guangrong
If the guest is 32-bit, we should use 'quadrant' to adjust gpa offset Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h

[PATCH 2/10] KVM MMU: convert mmu tracepoints

2010-04-22 Thread Xiao Guangrong
Convert mmu tracepoints by using DECLARE_EVENT_CLASS Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmutrace.h | 69 +- 1 files changed, 26 insertions(+), 43 deletions(-) diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86

[PATCH 3/10] KVM MMU: move unsync/sync tracpoints to proper place

2010-04-22 Thread Xiao Guangrong
Move unsync/sync tracepoints to the proper place, it's good for us to obtain unsync page live time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c

[PATCH 4/10] KVM MMU: Move invlpg code out of paging_tmpl.h

2010-04-22 Thread Xiao Guangrong
Using '!sp-role.cr4_pae' replaces 'PTTYPE == 32' and using 'pte_size = sp-role.cr4_pae ? 8 : 4' replaces sizeof(pt_element_t) Then no need compile twice for this code Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 60

[PATCH 5/10] KVM MMU: cleanup invlpg code

2010-04-22 Thread Xiao Guangrong
Using is_last_spte() to cleanup invlpg code Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index fac7c09..fd027a6 100644 --- a/arch/x86/kvm/mmu.c

[PATCH 6/10] KVM MMU: don't write-protect if have new mapping to unsync page

2010-04-22 Thread Xiao Guangrong
If have new mapping to the unsync page(i.e, add a new parent), just update the page from sp-gfn but not write-protect gfn, and if need create new shadow page form sp-gfn, we should sync it Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 27

[PATCH 7/10] KVM MMU: allow more page become unsync at gfn mapping time

2010-04-22 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 81 +++ 1 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 8607a64..13378e7 100644 --- a/arch

[PATCH 8/10] KVM MMU: allow more page become unsync at getting sp time

2010-04-22 Thread Xiao Guangrong
Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 0), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 22 -- 1 files

[PATCH 9/10] KVM MMU: separate invlpg code form kvm_mmu_pte_write()

2010-04-22 Thread Xiao Guangrong
Let invlpg not depends on kvm_mmu_pte_write path, later patch will need this feature Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 40 1 files changed, 24 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm

[PATCH 10/10] KVM MMU: optimize sync/update unsync-page

2010-04-22 Thread Xiao Guangrong
unsync page, the unsync page only updated at invlpg/flush TLB time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 10 ++ 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index f092e71..5bdcc17

Re: [PATCH 6/10] KVM MMU: don't write-protect if have new mapping to unsync page

2010-04-22 Thread Xiao Guangrong
Marcelo Tosatti wrote: role = vcpu-arch.mmu.base_role; @@ -1332,12 +1336,16 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, hlist_for_each_entry_safe(sp, node, tmp, bucket, hash_link) if (sp-gfn == gfn) { if (sp-unsync)

Re: [PATCH 1/3] KVM MMU: make kvm_mmu_zap_page() return the number of zapped sp in total.

2010-04-22 Thread Xiao Guangrong
Gui Jianfeng wrote: Currently, in kvm_mmu_change_mmu_pages(kvm, page), used_pages-- is performed after calling kvm_mmu_zap_page() in spite of that whether page is actually reclaimed. Because root sp won't be reclaimed by kvm_mmu_zap_page(). So making kvm_mmu_zap_page() return total

Re: [PATCH 1/10] KVM MMU: fix for calculating gpa in invlpg code

2010-04-23 Thread Xiao Guangrong
Avi Kivity wrote: On 04/22/2010 09:12 AM, Xiao Guangrong wrote: If the guest is 32-bit, we should use 'quadrant' to adjust gpa offset Good catch. Only affects kvm_mmu_pte_write(), so I don't think this had ill effects other than not prefetching the correct address? Yes

Re: [PATCH 4/10] KVM MMU: Move invlpg code out of paging_tmpl.h

2010-04-23 Thread Xiao Guangrong
Avi Kivity wrote: On 04/23/2010 02:27 PM, Avi Kivity wrote: On 04/22/2010 09:12 AM, Xiao Guangrong wrote: Using '!sp-role.cr4_pae' replaces 'PTTYPE == 32' and using 'pte_size = sp-role.cr4_pae ? 8 : 4' replaces sizeof(pt_element_t) Then no need compile twice for this code I think we

[PATCH v2 0/10] KVM MMU: allow more shadow pages become asynchronous

2010-04-25 Thread Xiao Guangrong
Changlog v2: - when level is PT_DIRECTORY_LEVEL, the 'offset' should be 'role.quadrant 8', thanks Avi for point it out - keep invlpg code in paging_tmpl.h address Avi's suggestion - split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's

[PATCH v2 1/10] KVM MMU: fix for calculating gpa in invlpg code

2010-04-25 Thread Xiao Guangrong
If the guest is 32-bit, we should use 'quadrant' to adjust gpa offset Changlog v2: - when level is PT_DIRECTORY_LEVEL, the 'offset' should be 'role.quadrant 8', thanks Avi for point it out Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h | 13

[PATCH v2 2/10] KVM MMU: convert mmu tracepoints

2010-04-25 Thread Xiao Guangrong
Convert mmu tracepoints by using DECLARE_EVENT_CLASS Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmutrace.h | 69 +- 1 files changed, 26 insertions(+), 43 deletions(-) diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86

[PATCH v2 3/10] KVM MMU: move unsync/sync tracpoints to proper place

2010-04-25 Thread Xiao Guangrong
Move unsync/sync tracepoints to the proper place, it's good for us to obtain unsync page live time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c

[PATCH v2 4/10] KVM MMU: cleanup invlpg code

2010-04-25 Thread Xiao Guangrong
Using is_last_spte() to cleanup invlpg code Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 83cc72f..8eb98eb 100644

[PATCH v2 5/10] KVM MMU: split kvm_sync_page() function

2010-04-25 Thread Xiao Guangrong
Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's suggestion kvm_sync_page_transient() function only update shadow page but not mark it sync and not write protect sp-gfn. it will be used by later patch Signed-off-by: Xiao Guangrong

[PATCH v2 6/10] KVM MMU: don't write-protect if have new mapping to unsync page

2010-04-25 Thread Xiao Guangrong
not allow to become unsync(also for the unsyc rule, the new rule is: allow all pte page become unsync) Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 14 +++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b

[PATCH v2 7/10] KVM MMU: allow more page become unsync at gfn mapping time

2010-04-25 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 81 +++ 1 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b946a5f..5198fc9 100644 --- a/arch

[PATCH v2 8/10] KVM MMU: allow more page become unsync at getting sp time

2010-04-25 Thread Xiao Guangrong
Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 1), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 21 +++-- 1 files changed

[PATCH v2 9/10] KVM MMU: separate invlpg code form kvm_mmu_pte_write()

2010-04-25 Thread Xiao Guangrong
Let invlpg not depends on kvm_mmu_pte_write path, later patch will need this feature Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 12 +++- arch/x86/kvm/paging_tmpl.h | 33 ++--- 2 files changed, 29 insertions

[PATCH v2 10/10] KVM MMU: optimize sync/update unsync-page

2010-04-25 Thread Xiao Guangrong
unsync page, the unsync page only updated at invlpg/flush TLB time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |3 ++- arch/x86/kvm/paging_tmpl.h | 23 +++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch

Re: [PATCH v2 1/10] KVM MMU: fix for calculating gpa in invlpg code

2010-04-25 Thread Xiao Guangrong
Avi Kivity wrote: On 04/25/2010 10:00 AM, Xiao Guangrong wrote: If the guest is 32-bit, we should use 'quadrant' to adjust gpa offset Changlog v2: - when level is PT_DIRECTORY_LEVEL, the 'offset' should be 'role.quadrant 8', thanks Avi for point it out Signed-off-by: Xiao

Re: [PATCH v2 5/10] KVM MMU: split kvm_sync_page() function

2010-04-25 Thread Xiao Guangrong
Avi Kivity wrote: This isn't a split; it duplicates the code. Since there are some parts in the middle of kvm_sync_page() you don't want in sync_page_transient(), you can put them into helpers so that sync_page and sync_page_transient only call helpers. Will fix it in v3, thanks

Re: [PATCH v2 9/10] KVM MMU: separate invlpg code form kvm_mmu_pte_write()

2010-04-25 Thread Xiao Guangrong
Avi Kivity wrote: On 04/25/2010 10:02 AM, Xiao Guangrong wrote: Let invlpg not depends on kvm_mmu_pte_write path, later patch will need this feature if (mmu_topup_memory_caches(vcpu)) return; -kvm_mmu_pte_write(vcpu, pte_gpa, NULL, sizeof(pt_element_t), 0

Re: [PATCH v2 6/10] KVM MMU: don't write-protect if have new mapping to unsync page

2010-04-25 Thread Xiao Guangrong
Avi Kivity wrote: On 04/25/2010 10:00 AM, Xiao Guangrong wrote: Two cases maybe happen in kvm_mmu_get_page() function: - one case is, the goal sp is already in cache, if the sp is unsync, we only need update it to assure this mapping is valid, but not mark it sync and not write

[PATCH v3 1/10] KVM MMU: fix for calculating gpa in invlpg code

2010-04-27 Thread Xiao Guangrong
If the guest is 32-bit, we should use 'quadrant' to adjust gpa offset Changelog v3: - use smart way to fix this bug address Avi's suggestion Changelog v2: - when level is PT_DIRECTORY_LEVEL, the 'offset' should be 'role.quadrant 8', thanks Avi for point it out Signed-off-by: Xiao Guangrong

[PATCH v3 4/10] KVM MMU: cleanup invlpg code

2010-04-27 Thread Xiao Guangrong
Using is_last_spte() to cleanup invlpg code Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 3464fdb..89d66ca 100644

[PATCH v3 5/10] KVM MMU: split kvm_sync_page() function

2010-04-27 Thread Xiao Guangrong
Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's suggestion kvm_sync_page_transient() function only update shadow page but not mark it sync and not write protect sp-gfn. it will be used by later patch Signed-off-by: Xiao Guangrong

[PATCH v3 7/10] KVM MMU: allow more page become unsync at gfn mapping time

2010-04-27 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 81 +++ 1 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index fb0c33c..a60cd51 100644 --- a/arch

[PATCH v3 2/10] KVM MMU: convert mmu tracepoints

2010-04-27 Thread Xiao Guangrong
Convert mmu tracepoints by using DECLARE_EVENT_CLASS Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmutrace.h | 69 +- 1 files changed, 26 insertions(+), 43 deletions(-) diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86

[PATCH v3 3/10] KVM MMU: move unsync/sync tracpoints to proper place

2010-04-27 Thread Xiao Guangrong
Move unsync/sync tracepoints to the proper place, it's good for us to obtain unsync page live time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c

[PATCH v3 6/10] KVM MMU: don't write-protect if have new mapping to unsync page

2010-04-27 Thread Xiao Guangrong
not allow to become unsync(also for the unsyc rule, the new rule is: allow all pte page become unsync) Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 14 +++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b

[PATCH v3 9/10] KVM MMU: separate invlpg code form kvm_mmu_pte_write()

2010-04-27 Thread Xiao Guangrong
Let invlpg not depends on kvm_mmu_pte_write path, later patch will need this feature Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 22 +- arch/x86/kvm/paging_tmpl.h | 36 +++- 2 files changed

[PATCH v3 10/10] KVM MMU: optimize sync/update unsync-page

2010-04-27 Thread Xiao Guangrong
unsync page, the unsync page only updated at invlpg/flush TLB time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |3 ++- arch/x86/kvm/paging_tmpl.h | 11 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b

Re: [PATCH v3 7/10] KVM MMU: allow more page become unsync at gfn mapping time

2010-05-05 Thread Xiao Guangrong
Marcelo Tosatti wrote: On Wed, Apr 28, 2010 at 11:55:49AM +0800, Xiao Guangrong wrote: In current code, shadow page can become asynchronous only if one shadow page for a gfn, this rule is too strict, in fact, we can let all last mapping page(i.e, it's the pte page) become unsync, and sync

[PATCH 1/2] KVM MMU: fix for forgot mark parent-unsync_children bit

2010-05-05 Thread Xiao Guangrong
When mapping a new parent to unsync shadow page, we should mark parent's unsync_children bit Reported-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff

[PATCH 2/2] KVM MMU: fix race in invlpg code

2010-05-05 Thread Xiao Guangrong
-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h | 22 -- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 624b38f..13ea675 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b

Re: [PATCH 1/2] KVM MMU: fix for forgot mark parent-unsync_children bit

2010-05-05 Thread Xiao Guangrong
Avi Kivity wrote: On 05/05/2010 03:19 PM, Xiao Guangrong wrote: When mapping a new parent to unsync shadow page, we should mark parent's unsync_children bit Reported-by: Marcelo Tosattimtosa...@redhat.com Signed-off-by: Xiao Guangrongxiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c

Re: [PATCH 2/2] KVM MMU: fix race in invlpg code

2010-05-05 Thread Xiao Guangrong
Avi Kivity wrote: spin_lock(vcpu-kvm-mmu_lock); +index = kvm_page_table_hashfn(gfn); +bucket =vcpu-kvm-arch.mmu_page_hash[index]; +hlist_for_each_entry_safe(s, node, tmp, bucket, hash_link) +if (s == sp) { +if (s-gfn == gfn s-role.word == role.word)

Re: [PATCH 4/4] KVM MMU: do not intercept invlpg if 'oos_shadow' is disabled

2010-05-05 Thread Xiao Guangrong
Avi Kivity wrote: On 04/30/2010 12:05 PM, Xiao Guangrong wrote: If 'oos_shadow' == 0, intercepting invlpg command is really unnecessary. And it's good for us to compare the performance between enable 'oos_shadow' and disable 'oos_shadow' @@ -74,8 +74,9 @@ static int dbg = 0

[PATCH v4 0/9] KVM MMU: allow more shadow pages become asynchronous

2010-05-06 Thread Xiao Guangrong
Changlog v4: - fix the bug that reported by Marcelo - fix the race in invlpg code Changlog v3: Those changes all form Avi's suggestion, thanks. - use smart way to fix the bug in patch 1 - remove duplicates code in patch 5 - check error code and fix forgot release page in patch 9 - sync shadow

[PATCH v4 1/9] KVM MMU: split kvm_sync_page() function

2010-05-06 Thread Xiao Guangrong
Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's suggestion kvm_sync_page_transient() function only update shadow page but not mark it sync and not write protect sp-gfn. it will be used by later patch Signed-off-by: Xiao Guangrong

[PATCH v4 2/9] KVM MMU: don't write-protect if have new mapping to unsync page

2010-05-06 Thread Xiao Guangrong
not allow to become unsync(also for the unsyc rule, the new rule is: allow all pte page become unsync) Changlog: - fix for forget to mark parent's unsync_children bit when mapping a new parent to unsync shadow page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm

[PATCH v4 3/9] KVM MMU: allow more page become unsync at gfn mapping time

2010-05-06 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 81 +++ 1 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 1dbb96e..ae8c43b 100644 --- a/arch

[PATCH v4 4/9] KVM MMU: allow more page become unsync at getting sp time

2010-05-06 Thread Xiao Guangrong
Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 1), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 47

[PATCH v4 5/9] KVM MMU: rename 'root_count' to 'active_count'

2010-05-06 Thread Xiao Guangrong
Rename 'root_count' to 'active_count' in kvm_mmu_page, since the unsync pages also will use it in later patch Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |7 ++- arch/x86/kvm/mmu.c | 14 +++--- arch/x86/kvm

[PATCH v4 6/9] KVM MMU: support keeping sp live while it's out of protection

2010-05-06 Thread Xiao Guangrong
() then we can free the invalid unsync page to call kvm_mmu_free_page directly. Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 15 +-- 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 58cf0f1

[PATCH v4 7/9] KVM MMU: separate invlpg code form kvm_mmu_pte_write()

2010-05-06 Thread Xiao Guangrong
Let invlpg not depends on kvm_mmu_pte_write path, later patch will need this feature Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 22 +- arch/x86/kvm/paging_tmpl.h | 44 +++- 2 files

[PATCH v4 8/9] KVM MMU: no need atomic operation for 'invlpg_counter'

2010-05-06 Thread Xiao Guangrong
'invlpg_counter' is protected by 'kvm-mmu_lock', no need atomic operation anymore Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |2 +- arch/x86/kvm/paging_tmpl.h |7 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git

[PATCH v4 9/9] KVM MMU: optimize sync/update unsync-page

2010-05-06 Thread Xiao Guangrong
unsync page, the unsync page only updated at invlpg/flush TLB time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |3 ++- arch/x86/kvm/paging_tmpl.h | 12 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c

Re: [PATCH v4 0/9] KVM MMU: allow more shadow pages become asynchronous

2010-05-06 Thread Xiao Guangrong
Hi Avi, Marcelo, patch 5 and patch 6 are can't apply to current kvm tree, i'll rebase those two patches. Marcelo, does this patchset fix your issue? I have tested it with Fedora12/Ubuntu/CentOS 32/64 guests, it works well. Thanks, Xiao -- To unsubscribe from this list: send the line unsubscribe

[PATCH v5 5/9] KVM MMU: rename 'root_count' to 'active_count'

2010-05-06 Thread Xiao Guangrong
Rename 'root_count' to 'active_count' in kvm_mmu_page, since the unsync pages also will use it in later patch Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/include/asm/kvm_host.h |8 +++- arch/x86/kvm/mmu.c | 14 +++--- arch/x86/kvm

[PATCH v5 6/9] KVM MMU: support keeping sp live while it's out of protection

2010-05-06 Thread Xiao Guangrong
() then we can free the invalid unsync page to call kvm_mmu_free_page directly. Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 11 +++ 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 4077a9c

[PATCH 1/5] KVM MMU: fix objects free

2010-05-12 Thread Xiao Guangrong
Where to alloc, where to free Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 18 ++ 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 604eb3f..67da751 100644 --- a/arch/x86/kvm

[PATCH 2/5] KVM MMU: remove rmap before clear spte

2010-05-12 Thread Xiao Guangrong
Remove rmap before clear spte otherwise it will trigger BUG_ON() in some functions such as rmap_write_protect() Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86

[PATCH 3/5] KVM MMU: fix for got gfn when sync shadow pages

2010-05-12 Thread Xiao Guangrong
sp-gfns[] are not mapping gfn since it has cooked by unalias_gfn() Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h

[PATCH 4/5] KVM MMU: fix two typos

2010-05-12 Thread Xiao Guangrong
fix two typos in next branch Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index a474d93..68f79b0 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86

[PATCH 1/3] KVM: MMU: split kvm_sync_page() function

2010-05-15 Thread Xiao Guangrong
Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient() to clarify the code address Avi's suggestion kvm_sync_page_transient() function only update shadow page but not mark it sync and not write protect sp-gfn. it will be used by later patch Signed-off-by: Xiao Guangrong

[PATCH 2/3] KVM: MMU: don't write-protect if have new mapping to unsync page

2010-05-15 Thread Xiao Guangrong
not allow to become unsync(also for the unsyc rule, the new rule is: allow all pte page become unsync) Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 18 ++ 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu.c

[PATCH 3/3] KVM: MMU: only update unsync page in invlpg path

2010-05-15 Thread Xiao Guangrong
Only unsync pages need updated at invlpg time since other shadow pages are write-protected Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/paging_tmpl.h |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch

[PATCH 1/2] KVM: MMU: allow more page become unsync at gfn mapping time

2010-05-23 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 81 +++ 1 files changed, 37 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 97c5217..1c558ba 100644 --- a/arch

[PATCH 2/2] KVM: MMU: allow more page become unsync at getting sp time

2010-05-23 Thread Xiao Guangrong
Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 1), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 47

Re: [PATCH 1/2] KVM: MMU: allow more page become unsync at gfn mapping time

2010-05-23 Thread Xiao Guangrong
Avi Kivity wrote: +if (need_unsync) +kvm_unsync_pages(vcpu, gfn); return 0; } Looks good, I'm just uncertain about role.invalid handling. What's the reasoning here? Avi, Thanks for your reply. We no need worry about 'role.invalid' here, since we only allow

Re: [PATCH 2/2] KVM: MMU: allow more page become unsync at getting sp time

2010-05-23 Thread Xiao Guangrong
Avi Kivity wrote: On 05/23/2010 03:16 PM, Xiao Guangrong wrote: Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 1), we should unsync all gfn's unsync page +/* @gfn should be write-protected at the call site

Re: [PATCH 1/2] KVM: MMU: allow more page become unsync at gfn mapping time

2010-05-24 Thread Xiao Guangrong
Avi Kivity wrote: On 05/24/2010 05:03 AM, Xiao Guangrong wrote: Avi Kivity wrote: +if (need_unsync) +kvm_unsync_pages(vcpu, gfn); return 0; } Looks good, I'm just uncertain about role.invalid handling. What's the reasoning here? Avi

[PATCH 1/2 v2] KVM: MMU: allow more page become unsync at gfn mapping time

2010-05-24 Thread Xiao Guangrong
mapping time Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 82 1 files changed, 38 insertions(+), 44 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 97c5217..170c8f7 100644 --- a/arch

[PATCH 2/2 v2] KVM: MMU: allow more page become unsync at getting sp time

2010-05-24 Thread Xiao Guangrong
Allow more page become asynchronous at getting sp time, if need create new shadow page for gfn but it not allow unsync(level 1), we should unsync all gfn's unsync page Signed-off-by: Xiao Guangrong xiaoguangr...@cn.fujitsu.com --- arch/x86/kvm/mmu.c | 47

  1   2   3   4   5   6   7   8   9   10   >