* [PATCH] kvm mmu: optimizations when tdp is in use
@ 2010-05-27 8:06 Gui Jianfeng
2010-05-27 8:33 ` Avi Kivity
2010-05-27 12:40 ` Marcelo Tosatti
0 siblings, 2 replies; 4+ messages in thread
From: Gui Jianfeng @ 2010-05-27 8:06 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
In case of using tdp, checking write protected page isn't needed and
quadrant also no need to be calculated.
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
arch/x86/kvm/mmu.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 0bb9f17..ce4bbd3 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
max_level = kvm_x86_ops->get_lpage_level() < host_level ?
kvm_x86_ops->get_lpage_level() : host_level;
+ if (tdp_enabled)
+ goto done;
+
for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level)
if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
break;
-
+done:
return level - 1;
}
@@ -1346,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
if (role.direct)
role.cr4_pae = 0;
role.access = access;
- if (vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
+ if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level));
quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1;
role.quadrant = quadrant;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm mmu: optimizations when tdp is in use
2010-05-27 8:06 [PATCH] kvm mmu: optimizations when tdp is in use Gui Jianfeng
@ 2010-05-27 8:33 ` Avi Kivity
2010-05-27 12:40 ` Marcelo Tosatti
1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2010-05-27 8:33 UTC (permalink / raw)
To: Gui Jianfeng; +Cc: kvm
On 05/27/2010 11:06 AM, Gui Jianfeng wrote:
> In case of using tdp, checking write protected page isn't needed and
> quadrant also no need to be calculated.
>
> Signed-off-by: Gui Jianfeng<guijianfeng@cn.fujitsu.com>
> ---
> arch/x86/kvm/mmu.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 0bb9f17..ce4bbd3 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
> max_level = kvm_x86_ops->get_lpage_level()< host_level ?
> kvm_x86_ops->get_lpage_level() : host_level;
>
> + if (tdp_enabled)
> + goto done;
> +
> for (level = PT_DIRECTORY_LEVEL; level<= max_level; ++level)
> if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
> break;
> -
> +done:
> return level - 1;
> }
>
>
We also use ->write_count to prevent mapping the end of a
non-large-page-aligned memslot with a large spte.
Undocumented in mmu.txt, I'll post a patch.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm mmu: optimizations when tdp is in use
2010-05-27 8:06 [PATCH] kvm mmu: optimizations when tdp is in use Gui Jianfeng
2010-05-27 8:33 ` Avi Kivity
@ 2010-05-27 12:40 ` Marcelo Tosatti
2010-05-28 0:24 ` Gui Jianfeng
1 sibling, 1 reply; 4+ messages in thread
From: Marcelo Tosatti @ 2010-05-27 12:40 UTC (permalink / raw)
To: Gui Jianfeng; +Cc: Avi Kivity, kvm
On Thu, May 27, 2010 at 04:06:34PM +0800, Gui Jianfeng wrote:
> In case of using tdp, checking write protected page isn't needed and
> quadrant also no need to be calculated.
>
> Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
> ---
> arch/x86/kvm/mmu.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 0bb9f17..ce4bbd3 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
> max_level = kvm_x86_ops->get_lpage_level() < host_level ?
> kvm_x86_ops->get_lpage_level() : host_level;
>
> + if (tdp_enabled)
> + goto done;
> +
This is wrong. write_count is initialized for alignment purposes, not
only write protected pages. See __kvm_set_memory_region in
virt/kvm/kvm_main.c.
> for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level)
> if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
> break;
> -
> +done:
> return level - 1;
> }
>
> @@ -1346,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
> if (role.direct)
> role.cr4_pae = 0;
> role.access = access;
> - if (vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
> + if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
> quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level));
> quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1;
> role.quadrant = quadrant;
> --
> 1.6.5.2
> --
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm mmu: optimizations when tdp is in use
2010-05-27 12:40 ` Marcelo Tosatti
@ 2010-05-28 0:24 ` Gui Jianfeng
0 siblings, 0 replies; 4+ messages in thread
From: Gui Jianfeng @ 2010-05-28 0:24 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Avi Kivity, kvm
Marcelo Tosatti wrote:
> On Thu, May 27, 2010 at 04:06:34PM +0800, Gui Jianfeng wrote:
>> In case of using tdp, checking write protected page isn't needed and
>> quadrant also no need to be calculated.
>>
>> Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
>> ---
>> arch/x86/kvm/mmu.c | 7 +++++--
>> 1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>> index 0bb9f17..ce4bbd3 100644
>> --- a/arch/x86/kvm/mmu.c
>> +++ b/arch/x86/kvm/mmu.c
>> @@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
>> max_level = kvm_x86_ops->get_lpage_level() < host_level ?
>> kvm_x86_ops->get_lpage_level() : host_level;
>>
>> + if (tdp_enabled)
>> + goto done;
>> +
>
> This is wrong. write_count is initialized for alignment purposes, not
> only write protected pages. See __kvm_set_memory_region in
> virt/kvm/kvm_main.c.
thanks, avi also pointed this out.
Gui
>
>> for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level)
>> if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
>> break;
>> -
>> +done:
>> return level - 1;
>> }
>>
>> @@ -1346,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
>> if (role.direct)
>> role.cr4_pae = 0;
>> role.access = access;
>> - if (vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
>> + if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
>> quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level));
>> quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1;
>> role.quadrant = quadrant;
>> --
>> 1.6.5.2
>> --
>> 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
>
>
--
Regards
Gui Jianfeng
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-28 0:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27 8:06 [PATCH] kvm mmu: optimizations when tdp is in use Gui Jianfeng
2010-05-27 8:33 ` Avi Kivity
2010-05-27 12:40 ` Marcelo Tosatti
2010-05-28 0:24 ` Gui Jianfeng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).