diff mbox

[v2,01/15] KVM: MMU: fix the count of spte number

Message ID 1378376958-27252-2-git-send-email-xiaoguangrong@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Sept. 5, 2013, 10:29 a.m. UTC
If the desc is the last one and it is full, its sptes is not counted

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/mmu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Gleb Natapov Sept. 8, 2013, 12:19 p.m. UTC | #1
On Thu, Sep 05, 2013 at 06:29:04PM +0800, Xiao Guangrong wrote:
> If the desc is the last one and it is full, its sptes is not counted
> 
Hmm, if desc is not full but it is not the last one all sptes after the
desc are not counted too.

> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
> ---
>  arch/x86/kvm/mmu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 6e2d2c8..7714fd8 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -948,6 +948,7 @@ static int pte_list_add(struct kvm_vcpu *vcpu, u64 *spte,
>  			count += PTE_LIST_EXT;
>  		}
>  		if (desc->sptes[PTE_LIST_EXT-1]) {
> +			count += PTE_LIST_EXT;
>  			desc->more = mmu_alloc_pte_list_desc(vcpu);
>  			desc = desc->more;
>  		}
> -- 
> 1.8.1.4

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Sept. 8, 2013, 1:55 p.m. UTC | #2
On Sep 8, 2013, at 8:19 PM, Gleb Natapov <gleb@redhat.com> wrote:

> On Thu, Sep 05, 2013 at 06:29:04PM +0800, Xiao Guangrong wrote:
>> If the desc is the last one and it is full, its sptes is not counted
>> 
> Hmm, if desc is not full but it is not the last one all sptes after the
> desc are not counted too.

But the desc must be the last one if it's not full since we always add
new entry or delete entry from the last desc.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov Sept. 8, 2013, 2:01 p.m. UTC | #3
On Sun, Sep 08, 2013 at 09:55:04PM +0800, Xiao Guangrong wrote:
> 
> On Sep 8, 2013, at 8:19 PM, Gleb Natapov <gleb@redhat.com> wrote:
> 
> > On Thu, Sep 05, 2013 at 06:29:04PM +0800, Xiao Guangrong wrote:
> >> If the desc is the last one and it is full, its sptes is not counted
> >> 
> > Hmm, if desc is not full but it is not the last one all sptes after the
> > desc are not counted too.
> 
> But the desc must be the last one if it's not full since we always add
> new entry or delete entry from the last desc.
> 
Why do we alway delete entries from last desc? We delete them from the
desc we found them in. Current code does not try to move entries between
descs, only inside a desc.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Sept. 8, 2013, 2:24 p.m. UTC | #4
On Sep 8, 2013, at 10:01 PM, Gleb Natapov <gleb@redhat.com> wrote:

> On Sun, Sep 08, 2013 at 09:55:04PM +0800, Xiao Guangrong wrote:
>> 
>> On Sep 8, 2013, at 8:19 PM, Gleb Natapov <gleb@redhat.com> wrote:
>> 
>>> On Thu, Sep 05, 2013 at 06:29:04PM +0800, Xiao Guangrong wrote:
>>>> If the desc is the last one and it is full, its sptes is not counted
>>>> 
>>> Hmm, if desc is not full but it is not the last one all sptes after the
>>> desc are not counted too.
>> 
>> But the desc must be the last one if it's not full since we always add
>> new entry or delete entry from the last desc.
>> 
> Why do we alway delete entries from last desc? We delete them from the
> desc we found them in. Current code does not try to move entries between
> descs, only inside a desc.

Oh, yes. Sorry, my memory is wrong… :(

So, currently there has some gaps in desc and it wastes memory.  Can not fix
them with simple change and  i think it is not worthy to fix them separately since
after my new algorithm, these should all be fixed… so how about just drop this
fix?



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov Sept. 8, 2013, 2:26 p.m. UTC | #5
On Sun, Sep 08, 2013 at 10:24:05PM +0800, Xiao Guangrong wrote:
> 
> On Sep 8, 2013, at 10:01 PM, Gleb Natapov <gleb@redhat.com> wrote:
> 
> > On Sun, Sep 08, 2013 at 09:55:04PM +0800, Xiao Guangrong wrote:
> >> 
> >> On Sep 8, 2013, at 8:19 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> 
> >>> On Thu, Sep 05, 2013 at 06:29:04PM +0800, Xiao Guangrong wrote:
> >>>> If the desc is the last one and it is full, its sptes is not counted
> >>>> 
> >>> Hmm, if desc is not full but it is not the last one all sptes after the
> >>> desc are not counted too.
> >> 
> >> But the desc must be the last one if it's not full since we always add
> >> new entry or delete entry from the last desc.
> >> 
> > Why do we alway delete entries from last desc? We delete them from the
> > desc we found them in. Current code does not try to move entries between
> > descs, only inside a desc.
> 
> Oh, yes. Sorry, my memory is wrong… :(
> 
> So, currently there has some gaps in desc and it wastes memory.  Can not fix
> them with simple change and  i think it is not worthy to fix them separately since
> after my new algorithm, these should all be fixed… so how about just drop this
> fix?
> 
Yes, if we are going to change algorithm anyway no need to spend time
fixing what we have now.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 6e2d2c8..7714fd8 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -948,6 +948,7 @@  static int pte_list_add(struct kvm_vcpu *vcpu, u64 *spte,
 			count += PTE_LIST_EXT;
 		}
 		if (desc->sptes[PTE_LIST_EXT-1]) {
+			count += PTE_LIST_EXT;
 			desc->more = mmu_alloc_pte_list_desc(vcpu);
 			desc = desc->more;
 		}