public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles
@ 2010-04-16  9:16 Gui Jianfeng
  2010-04-16  9:18 ` [PATCH 2/4] KVM: Make use of is_large_pte() instead Gui Jianfeng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gui Jianfeng @ 2010-04-16  9:16 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Move first pte address calculation out of loop to save some cycles

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
 arch/x86/kvm/paging_tmpl.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index d9dea28..5910557 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -572,12 +572,15 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
 {
 	int i, offset, nr_present;
 	bool reset_host_protection;
+	gpa_t first_pte_gpa;
 
 	offset = nr_present = 0;
 
 	if (PTTYPE == 32)
 		offset = sp->role.quadrant << PT64_LEVEL_BITS;
 
+	first_pte_gpa = gfn_to_gpa(sp->gfn) + offset * sizeof(pt_element_t);
+
 	for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
 		unsigned pte_access;
 		pt_element_t gpte;
@@ -587,8 +590,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
 		if (!is_shadow_present_pte(sp->spt[i]))
 			continue;
 
-		pte_gpa = gfn_to_gpa(sp->gfn);
-		pte_gpa += (i+offset) * sizeof(pt_element_t);
+		pte_gpa = first_pte_gpa + i * sizeof(pt_element_t);
 
 		if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte,
 					  sizeof(pt_element_t)))
-- 
1.6.5.2





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] KVM: Make use of is_large_pte() instead
  2010-04-16  9:16 [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Gui Jianfeng
@ 2010-04-16  9:18 ` Gui Jianfeng
  2010-04-16  9:18 ` [PATCH 3/4] KVM: Remove unused varialbe in rmap_next() Gui Jianfeng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gui Jianfeng @ 2010-04-16  9:18 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Make use of is_large_pte() instead of checking PT_PAGE_SIZE_MASK 
bit directly.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
 arch/x86/kvm/paging_tmpl.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 5910557..d0cc07e 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -190,10 +190,10 @@ walk:
 
 		if ((walker->level == PT_PAGE_TABLE_LEVEL) ||
 		    ((walker->level == PT_DIRECTORY_LEVEL) &&
-				(pte & PT_PAGE_SIZE_MASK)  &&
+				is_large_pte(pte) &&
 				(PTTYPE == 64 || is_pse(vcpu))) ||
 		    ((walker->level == PT_PDPE_LEVEL) &&
-				(pte & PT_PAGE_SIZE_MASK)  &&
+				is_large_pte(pte) &&
 				is_long_mode(vcpu))) {
 			int lvl = walker->level;
 
-- 1.6.5.2 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] KVM: Remove unused varialbe in rmap_next()
  2010-04-16  9:16 [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Gui Jianfeng
  2010-04-16  9:18 ` [PATCH 2/4] KVM: Make use of is_large_pte() instead Gui Jianfeng
@ 2010-04-16  9:18 ` Gui Jianfeng
  2010-04-16  9:19 ` [PATCH 4/4] KVM: Get rid of dead function Gui Jianfeng
  2010-04-21  9:03 ` [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Avi Kivity
  3 siblings, 0 replies; 5+ messages in thread
From: Gui Jianfeng @ 2010-04-16  9:18 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Remove unused varialbe in rmap_next()

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
 arch/x86/kvm/mmu.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index b44380b..dec8a6d 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -651,7 +651,6 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
 static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte)
 {
 	struct kvm_rmap_desc *desc;
-	struct kvm_rmap_desc *prev_desc;
 	u64 *prev_spte;
 	int i;
 
@@ -663,7 +662,6 @@ static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte)
 		return NULL;
 	}
 	desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul);
-	prev_desc = NULL;
 	prev_spte = NULL;
 	while (desc) {
 		for (i = 0; i < RMAP_EXT && desc->sptes[i]; ++i) {
-- 1.6.5.2 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] KVM: Get rid of dead function
  2010-04-16  9:16 [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Gui Jianfeng
  2010-04-16  9:18 ` [PATCH 2/4] KVM: Make use of is_large_pte() instead Gui Jianfeng
  2010-04-16  9:18 ` [PATCH 3/4] KVM: Remove unused varialbe in rmap_next() Gui Jianfeng
@ 2010-04-16  9:19 ` Gui Jianfeng
  2010-04-21  9:03 ` [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Avi Kivity
  3 siblings, 0 replies; 5+ messages in thread
From: Gui Jianfeng @ 2010-04-16  9:19 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

Nobody use gva_to_page() anymore, get rid of it.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
 arch/x86/kvm/mmu.c       |   14 --------------
 include/linux/kvm_host.h |    1 -
 2 files changed, 0 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index dec8a6d..bb18917 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1619,20 +1619,6 @@ static void mmu_convert_notrap(struct kvm_mmu_page *sp)
 	}
 }
 
-struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva)
-{
-	struct page *page;
-
-	gpa_t gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL);
-
-	if (gpa == UNMAPPED_GVA)
-		return NULL;
-
-	page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
-
-	return page;
-}
-
 /*
  * The function is based on mtrr_type_lookup() in
  * arch/x86/kernel/cpu/mtrr/generic.c
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 169d077..f1aabe2 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -247,7 +247,6 @@ void kvm_put_kvm(struct kvm *kvm);
 #define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
 #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
 static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
-struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
 
 extern struct page *bad_page;
 extern pfn_t bad_pfn;
-- 1.6.5.2 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles
  2010-04-16  9:16 [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Gui Jianfeng
                   ` (2 preceding siblings ...)
  2010-04-16  9:19 ` [PATCH 4/4] KVM: Get rid of dead function Gui Jianfeng
@ 2010-04-21  9:03 ` Avi Kivity
  3 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-04-21  9:03 UTC (permalink / raw)
  To: Gui Jianfeng; +Cc: kvm

On 04/16/2010 12:16 PM, Gui Jianfeng wrote:
> Move first pte address calculation out of loop to save some cycles
>    

Applied all four patches, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-21  9:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-16  9:16 [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Gui Jianfeng
2010-04-16  9:18 ` [PATCH 2/4] KVM: Make use of is_large_pte() instead Gui Jianfeng
2010-04-16  9:18 ` [PATCH 3/4] KVM: Remove unused varialbe in rmap_next() Gui Jianfeng
2010-04-16  9:19 ` [PATCH 4/4] KVM: Get rid of dead function Gui Jianfeng
2010-04-21  9:03 ` [PATCH 1/4] KVM: Move first pte address calculation out of loop to save some cycles Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox