kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled
@ 2020-07-28  9:45 Wanpeng Li
  2020-07-28  9:45 ` [PATCH v2 2/3] KVM: LAPIC: Set the APIC_TDCR settable bits Wanpeng Li
  2020-07-28  9:45 ` [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM Wanpeng Li
  0 siblings, 2 replies; 7+ messages in thread
From: Wanpeng Li @ 2020-07-28  9:45 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, stable

From: Wanpeng Li <wanpengli@tencent.com>

Prevent setting the tscdeadline timer if the lapic is hw disabled.

Fixes: bce87cce88 (KVM: x86: consolidate different ways to test for in-kernel LAPIC)
Cc: <stable@vger.kernel.org>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
 arch/x86/kvm/lapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5bf72fc..4ce2ddd 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2195,7 +2195,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!lapic_in_kernel(vcpu) || apic_lvtt_oneshot(apic) ||
+	if (!kvm_apic_present(vcpu) || apic_lvtt_oneshot(apic) ||
 			apic_lvtt_period(apic))
 		return;
 
-- 
2.7.4


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

* [PATCH v2 2/3] KVM: LAPIC: Set the APIC_TDCR settable bits
  2020-07-28  9:45 [PATCH v2 1/3] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled Wanpeng Li
@ 2020-07-28  9:45 ` Wanpeng Li
  2020-07-28  9:45 ` [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM Wanpeng Li
  1 sibling, 0 replies; 7+ messages in thread
From: Wanpeng Li @ 2020-07-28  9:45 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel

From: Wanpeng Li <wanpengli@tencent.com>

It is a little different between Intel and AMD, Intel's bit 2
is 0 and AMD is reserved. On bare-metal, Intel will refuse to set
APIC_TDCR once bits except 0, 1, 3 are setting, however, AMD will
accept bits 0, 1, 3 and ignore other bits setting as patch does.
Before the patch, we can get back anything what we set to the
APIC_TDCR, this patch improves it.

Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
 arch/x86/kvm/lapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 4ce2ddd..8f7a14d 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2068,7 +2068,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
 	case APIC_TDCR: {
 		uint32_t old_divisor = apic->divide_count;
 
-		kvm_lapic_set_reg(apic, APIC_TDCR, val);
+		kvm_lapic_set_reg(apic, APIC_TDCR, val & 0xb);
 		update_divide_count(apic);
 		if (apic->divide_count != old_divisor &&
 				apic->lapic_timer.period) {
-- 
2.7.4


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

* [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM
  2020-07-28  9:45 [PATCH v2 1/3] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled Wanpeng Li
  2020-07-28  9:45 ` [PATCH v2 2/3] KVM: LAPIC: Set the APIC_TDCR settable bits Wanpeng Li
@ 2020-07-28  9:45 ` Wanpeng Li
  2020-07-29 12:20   ` Vitaly Kuznetsov
  1 sibling, 1 reply; 7+ messages in thread
From: Wanpeng Li @ 2020-07-28  9:45 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel

From: Wanpeng Li <wanpengli@tencent.com>

Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops
disable pause loop exit/pause filtering capability completely, I guess it
is a merge fault by Radim since disable vmexits capabilities and pause
loop exit for SVM patchsets are merged at the same time. This patch
reintroduces the disable pause loop exit/pause filtering capability
support.

We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD 
Rome Server.

Reported-by: Haiwei Li <lihaiwei@tencent.com>
Tested-by: Haiwei Li <lihaiwei@tencent.com>
Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM)
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
 arch/x86/kvm/svm/svm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index c0da4dd..c20f127 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm)
 	svm->nested.vmcb = 0;
 	svm->vcpu.arch.hflags = 0;
 
-	if (pause_filter_count) {
+	if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) {
 		control->pause_filter_count = pause_filter_count;
 		if (pause_filter_thresh)
 			control->pause_filter_thresh = pause_filter_thresh;
@@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm)
 	struct kvm_vcpu *vcpu = &svm->vcpu;
 	bool in_kernel = (svm_get_cpl(vcpu) == 0);
 
-	if (pause_filter_thresh)
+	if (!kvm_pause_in_guest(vcpu->kvm))
 		grow_ple_window(vcpu);
 
 	kvm_vcpu_on_spin(vcpu, in_kernel);
@@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
 
 static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
 {
-	if (pause_filter_thresh)
+	if (!kvm_pause_in_guest(vcpu->kvm))
 		shrink_ple_window(vcpu);
 }
 
@@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm)
 
 static int svm_vm_init(struct kvm *kvm)
 {
+	if (!pause_filter_thresh)
+		kvm->arch.pause_in_guest = true;
+
 	if (avic) {
 		int ret = avic_vm_init(kvm);
 		if (ret)
-- 
2.7.4


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

* Re: [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM
  2020-07-28  9:45 ` [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM Wanpeng Li
@ 2020-07-29 12:20   ` Vitaly Kuznetsov
  2020-07-30  0:56     ` Wanpeng Li
  0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Kuznetsov @ 2020-07-29 12:20 UTC (permalink / raw)
  To: Wanpeng Li, linux-kernel, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Jim Mattson,
	Joerg Roedel

Wanpeng Li <kernellwp@gmail.com> writes:

> From: Wanpeng Li <wanpengli@tencent.com>
>
> Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops
> disable pause loop exit/pause filtering capability completely, I guess it
> is a merge fault by Radim since disable vmexits capabilities and pause
> loop exit for SVM patchsets are merged at the same time. This patch
> reintroduces the disable pause loop exit/pause filtering capability
> support.
>
> We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD 
> Rome Server.
>
> Reported-by: Haiwei Li <lihaiwei@tencent.com>
> Tested-by: Haiwei Li <lihaiwei@tencent.com>
> Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM)
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
>  arch/x86/kvm/svm/svm.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index c0da4dd..c20f127 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm)
>  	svm->nested.vmcb = 0;
>  	svm->vcpu.arch.hflags = 0;
>  
> -	if (pause_filter_count) {
> +	if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) {
>  		control->pause_filter_count = pause_filter_count;
>  		if (pause_filter_thresh)
>  			control->pause_filter_thresh = pause_filter_thresh;
> @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm)
>  	struct kvm_vcpu *vcpu = &svm->vcpu;
>  	bool in_kernel = (svm_get_cpl(vcpu) == 0);
>  
> -	if (pause_filter_thresh)
> +	if (!kvm_pause_in_guest(vcpu->kvm))
>  		grow_ple_window(vcpu);
>  
>  	kvm_vcpu_on_spin(vcpu, in_kernel);
> @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
>  
>  static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
>  {
> -	if (pause_filter_thresh)
> +	if (!kvm_pause_in_guest(vcpu->kvm))
>  		shrink_ple_window(vcpu);
>  }
>  
> @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm)
>  
>  static int svm_vm_init(struct kvm *kvm)
>  {
> +	if (!pause_filter_thresh)
> +		kvm->arch.pause_in_guest = true;

Would it make sense to do

        if (!pause_filter_count || !pause_filter_thresh)
		kvm->arch.pause_in_guest = true;

here and simplify the condition in init_vmcb()?

> +
>  	if (avic) {
>  		int ret = avic_vm_init(kvm);
>  		if (ret)

-- 
Vitaly


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

* Re: [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM
  2020-07-29 12:20   ` Vitaly Kuznetsov
@ 2020-07-30  0:56     ` Wanpeng Li
  2020-07-30 11:16       ` Vitaly Kuznetsov
  0 siblings, 1 reply; 7+ messages in thread
From: Wanpeng Li @ 2020-07-30  0:56 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: LKML, kvm, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
	Jim Mattson, Joerg Roedel

On Wed, 29 Jul 2020 at 20:21, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Wanpeng Li <kernellwp@gmail.com> writes:
>
> > From: Wanpeng Li <wanpengli@tencent.com>
> >
> > Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops
> > disable pause loop exit/pause filtering capability completely, I guess it
> > is a merge fault by Radim since disable vmexits capabilities and pause
> > loop exit for SVM patchsets are merged at the same time. This patch
> > reintroduces the disable pause loop exit/pause filtering capability
> > support.
> >
> > We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD
> > Rome Server.
> >
> > Reported-by: Haiwei Li <lihaiwei@tencent.com>
> > Tested-by: Haiwei Li <lihaiwei@tencent.com>
> > Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM)
> > Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> > ---
> >  arch/x86/kvm/svm/svm.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> > index c0da4dd..c20f127 100644
> > --- a/arch/x86/kvm/svm/svm.c
> > +++ b/arch/x86/kvm/svm/svm.c
> > @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm)
> >       svm->nested.vmcb = 0;
> >       svm->vcpu.arch.hflags = 0;
> >
> > -     if (pause_filter_count) {
> > +     if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) {
> >               control->pause_filter_count = pause_filter_count;
> >               if (pause_filter_thresh)
> >                       control->pause_filter_thresh = pause_filter_thresh;
> > @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm)
> >       struct kvm_vcpu *vcpu = &svm->vcpu;
> >       bool in_kernel = (svm_get_cpl(vcpu) == 0);
> >
> > -     if (pause_filter_thresh)
> > +     if (!kvm_pause_in_guest(vcpu->kvm))
> >               grow_ple_window(vcpu);
> >
> >       kvm_vcpu_on_spin(vcpu, in_kernel);
> > @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
> >
> >  static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
> >  {
> > -     if (pause_filter_thresh)
> > +     if (!kvm_pause_in_guest(vcpu->kvm))
> >               shrink_ple_window(vcpu);
> >  }
> >
> > @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm)
> >
> >  static int svm_vm_init(struct kvm *kvm)
> >  {
> > +     if (!pause_filter_thresh)
> > +             kvm->arch.pause_in_guest = true;
>
> Would it make sense to do
>
>         if (!pause_filter_count || !pause_filter_thresh)
>                 kvm->arch.pause_in_guest = true;
>
> here and simplify the condition in init_vmcb()?

kvm->arch.pause_in_guest can also be true when userspace sets the
KVM_CAP_X86_DISABLE_EXITS capability, so we can't simplify the
condition in init_vmcb().

    Wanpeng

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

* Re: [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM
  2020-07-30  0:56     ` Wanpeng Li
@ 2020-07-30 11:16       ` Vitaly Kuznetsov
  2020-07-31  3:18         ` Wanpeng Li
  0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Kuznetsov @ 2020-07-30 11:16 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: LKML, kvm, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
	Jim Mattson, Joerg Roedel

Wanpeng Li <kernellwp@gmail.com> writes:

> On Wed, 29 Jul 2020 at 20:21, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>>
>> Wanpeng Li <kernellwp@gmail.com> writes:
>>
>> > From: Wanpeng Li <wanpengli@tencent.com>
>> >
>> > Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops
>> > disable pause loop exit/pause filtering capability completely, I guess it
>> > is a merge fault by Radim since disable vmexits capabilities and pause
>> > loop exit for SVM patchsets are merged at the same time. This patch
>> > reintroduces the disable pause loop exit/pause filtering capability
>> > support.
>> >
>> > We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD
>> > Rome Server.
>> >
>> > Reported-by: Haiwei Li <lihaiwei@tencent.com>
>> > Tested-by: Haiwei Li <lihaiwei@tencent.com>
>> > Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM)
>> > Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
>> > ---
>> >  arch/x86/kvm/svm/svm.c | 9 ++++++---
>> >  1 file changed, 6 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>> > index c0da4dd..c20f127 100644
>> > --- a/arch/x86/kvm/svm/svm.c
>> > +++ b/arch/x86/kvm/svm/svm.c
>> > @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm)
>> >       svm->nested.vmcb = 0;
>> >       svm->vcpu.arch.hflags = 0;
>> >
>> > -     if (pause_filter_count) {
>> > +     if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) {
>> >               control->pause_filter_count = pause_filter_count;
>> >               if (pause_filter_thresh)
>> >                       control->pause_filter_thresh = pause_filter_thresh;
>> > @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm)
>> >       struct kvm_vcpu *vcpu = &svm->vcpu;
>> >       bool in_kernel = (svm_get_cpl(vcpu) == 0);
>> >
>> > -     if (pause_filter_thresh)
>> > +     if (!kvm_pause_in_guest(vcpu->kvm))
>> >               grow_ple_window(vcpu);
>> >
>> >       kvm_vcpu_on_spin(vcpu, in_kernel);
>> > @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
>> >
>> >  static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
>> >  {
>> > -     if (pause_filter_thresh)
>> > +     if (!kvm_pause_in_guest(vcpu->kvm))
>> >               shrink_ple_window(vcpu);
>> >  }
>> >
>> > @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm)
>> >
>> >  static int svm_vm_init(struct kvm *kvm)
>> >  {
>> > +     if (!pause_filter_thresh)
>> > +             kvm->arch.pause_in_guest = true;
>>
>> Would it make sense to do
>>
>>         if (!pause_filter_count || !pause_filter_thresh)
>>                 kvm->arch.pause_in_guest = true;
>>
>> here and simplify the condition in init_vmcb()?
>
> kvm->arch.pause_in_guest can also be true when userspace sets the
> KVM_CAP_X86_DISABLE_EXITS capability, so we can't simplify the
> condition in init_vmcb().
>

I meant we simplify it to

if (!kvm_pause_in_guest(svm->vcpu.kvm))

as "!pause_filter_count" gets included.

-- 
Vitaly


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

* Re: [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM
  2020-07-30 11:16       ` Vitaly Kuznetsov
@ 2020-07-31  3:18         ` Wanpeng Li
  0 siblings, 0 replies; 7+ messages in thread
From: Wanpeng Li @ 2020-07-31  3:18 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: LKML, kvm, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
	Jim Mattson, Joerg Roedel

On Thu, 30 Jul 2020 at 19:16, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Wanpeng Li <kernellwp@gmail.com> writes:
>
> > On Wed, 29 Jul 2020 at 20:21, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> >>
> >> Wanpeng Li <kernellwp@gmail.com> writes:
> >>
> >> > From: Wanpeng Li <wanpengli@tencent.com>
> >> >
> >> > Commit 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM) drops
> >> > disable pause loop exit/pause filtering capability completely, I guess it
> >> > is a merge fault by Radim since disable vmexits capabilities and pause
> >> > loop exit for SVM patchsets are merged at the same time. This patch
> >> > reintroduces the disable pause loop exit/pause filtering capability
> >> > support.
> >> >
> >> > We can observe 2.9% hackbench improvement for a 92 vCPUs guest on AMD
> >> > Rome Server.
> >> >
> >> > Reported-by: Haiwei Li <lihaiwei@tencent.com>
> >> > Tested-by: Haiwei Li <lihaiwei@tencent.com>
> >> > Fixes: 8566ac8b (KVM: SVM: Implement pause loop exit logic in SVM)
> >> > Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> >> > ---
> >> >  arch/x86/kvm/svm/svm.c | 9 ++++++---
> >> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >> >
> >> > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> >> > index c0da4dd..c20f127 100644
> >> > --- a/arch/x86/kvm/svm/svm.c
> >> > +++ b/arch/x86/kvm/svm/svm.c
> >> > @@ -1090,7 +1090,7 @@ static void init_vmcb(struct vcpu_svm *svm)
> >> >       svm->nested.vmcb = 0;
> >> >       svm->vcpu.arch.hflags = 0;
> >> >
> >> > -     if (pause_filter_count) {
> >> > +     if (pause_filter_count && !kvm_pause_in_guest(svm->vcpu.kvm)) {
> >> >               control->pause_filter_count = pause_filter_count;
> >> >               if (pause_filter_thresh)
> >> >                       control->pause_filter_thresh = pause_filter_thresh;
> >> > @@ -2693,7 +2693,7 @@ static int pause_interception(struct vcpu_svm *svm)
> >> >       struct kvm_vcpu *vcpu = &svm->vcpu;
> >> >       bool in_kernel = (svm_get_cpl(vcpu) == 0);
> >> >
> >> > -     if (pause_filter_thresh)
> >> > +     if (!kvm_pause_in_guest(vcpu->kvm))
> >> >               grow_ple_window(vcpu);
> >> >
> >> >       kvm_vcpu_on_spin(vcpu, in_kernel);
> >> > @@ -3780,7 +3780,7 @@ static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
> >> >
> >> >  static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
> >> >  {
> >> > -     if (pause_filter_thresh)
> >> > +     if (!kvm_pause_in_guest(vcpu->kvm))
> >> >               shrink_ple_window(vcpu);
> >> >  }
> >> >
> >> > @@ -3958,6 +3958,9 @@ static void svm_vm_destroy(struct kvm *kvm)
> >> >
> >> >  static int svm_vm_init(struct kvm *kvm)
> >> >  {
> >> > +     if (!pause_filter_thresh)
> >> > +             kvm->arch.pause_in_guest = true;
> >>
> >> Would it make sense to do
> >>
> >>         if (!pause_filter_count || !pause_filter_thresh)
> >>                 kvm->arch.pause_in_guest = true;
> >>
> >> here and simplify the condition in init_vmcb()?
> >
> > kvm->arch.pause_in_guest can also be true when userspace sets the
> > KVM_CAP_X86_DISABLE_EXITS capability, so we can't simplify the
> > condition in init_vmcb().
> >
>
> I meant we simplify it to
>
> if (!kvm_pause_in_guest(svm->vcpu.kvm))
>
> as "!pause_filter_count" gets included.

Just do it in v3.

    Wanpeng

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

end of thread, other threads:[~2020-07-31  3:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  9:45 [PATCH v2 1/3] KVM: LAPIC: Prevent setting the tscdeadline timer if the lapic is hw disabled Wanpeng Li
2020-07-28  9:45 ` [PATCH v2 2/3] KVM: LAPIC: Set the APIC_TDCR settable bits Wanpeng Li
2020-07-28  9:45 ` [PATCH v2 3/3] KVM: SVM: Fix disable pause loop exit/pause filtering capability on SVM Wanpeng Li
2020-07-29 12:20   ` Vitaly Kuznetsov
2020-07-30  0:56     ` Wanpeng Li
2020-07-30 11:16       ` Vitaly Kuznetsov
2020-07-31  3:18         ` Wanpeng Li

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).