linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] svm/avic: Do not send AVIC doorbell to self
@ 2019-05-03 13:38 Suthikulpanit, Suravee
  2019-05-07 13:16 ` Graf, Alexander
  2019-05-20 12:56 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Suthikulpanit, Suravee @ 2019-05-03 13:38 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: pbonzini, rkrcmar, joro, Suthikulpanit, Suravee

AVIC doorbell is used to notify a running vCPU that interrupts
has been injected into the vCPU AVIC backing page. Current logic
checks only if a VCPU is running before sending a doorbell.
However, the doorbell is not necessary if the destination
CPU is itself.

Add logic to check currently running CPU before sending doorbell.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 arch/x86/kvm/svm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 122788f..4bbf6fc 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5283,10 +5283,13 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
 	kvm_lapic_set_irr(vec, vcpu->arch.apic);
 	smp_mb__after_atomic();
 
-	if (avic_vcpu_is_running(vcpu))
-		wrmsrl(SVM_AVIC_DOORBELL,
-		       kvm_cpu_get_apicid(vcpu->cpu));
-	else
+	if (avic_vcpu_is_running(vcpu)) {
+		int cpuid = vcpu->cpu;
+
+		if (cpuid != get_cpu())
+			wrmsrl(SVM_AVIC_DOORBELL, kvm_cpu_get_apicid(cpuid));
+		put_cpu();
+	} else
 		kvm_vcpu_wake_up(vcpu);
 }
 
-- 
1.8.3.1


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

* Re: [PATCH] svm/avic: Do not send AVIC doorbell to self
  2019-05-03 13:38 [PATCH] svm/avic: Do not send AVIC doorbell to self Suthikulpanit, Suravee
@ 2019-05-07 13:16 ` Graf, Alexander
  2019-05-14 15:52   ` Suthikulpanit, Suravee
  2019-05-20 12:56 ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Graf, Alexander @ 2019-05-07 13:16 UTC (permalink / raw)
  To: Suthikulpanit, Suravee, linux-kernel, kvm; +Cc: pbonzini, rkrcmar, joro

On 03.05.19 15:38, Suthikulpanit, Suravee wrote:
> AVIC doorbell is used to notify a running vCPU that interrupts
> has been injected into the vCPU AVIC backing page. Current logic
> checks only if a VCPU is running before sending a doorbell.
> However, the doorbell is not necessary if the destination
> CPU is itself.
> 
> Add logic to check currently running CPU before sending doorbell.
> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

Reviewed-by: Alexander Graf <graf@amazon.com>

> ---
>   arch/x86/kvm/svm.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 122788f..4bbf6fc 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -5283,10 +5283,13 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
>   	kvm_lapic_set_irr(vec, vcpu->arch.apic);
>   	smp_mb__after_atomic();
>   
> -	if (avic_vcpu_is_running(vcpu))
> -		wrmsrl(SVM_AVIC_DOORBELL,
> -		       kvm_cpu_get_apicid(vcpu->cpu));
> -	else
> +	if (avic_vcpu_is_running(vcpu)) { > +		int cpuid = vcpu->cpu;
> +
> +		if (cpuid != get_cpu())

Tiny nitpick: What would keep you from checking vcpu->cpu directly here?

Alex

> +			wrmsrl(SVM_AVIC_DOORBELL, kvm_cpu_get_apicid(cpuid));
> +		put_cpu();
> +	} else
>   		kvm_vcpu_wake_up(vcpu);
>   }
>   
> 


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

* Re: [PATCH] svm/avic: Do not send AVIC doorbell to self
  2019-05-07 13:16 ` Graf, Alexander
@ 2019-05-14 15:52   ` Suthikulpanit, Suravee
  0 siblings, 0 replies; 4+ messages in thread
From: Suthikulpanit, Suravee @ 2019-05-14 15:52 UTC (permalink / raw)
  To: Graf, Alexander, linux-kernel, kvm; +Cc: pbonzini, rkrcmar, joro

Alex,

On 5/7/2019 8:16 AM, Graf, Alexander wrote:
> [CAUTION: External Email]
> 
> On 03.05.19 15:38, Suthikulpanit, Suravee wrote:
>> AVIC doorbell is used to notify a running vCPU that interrupts
>> has been injected into the vCPU AVIC backing page. Current logic
>> checks only if a VCPU is running before sending a doorbell.
>> However, the doorbell is not necessary if the destination
>> CPU is itself.
>>
>> Add logic to check currently running CPU before sending doorbell.
>>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> 
> Reviewed-by: Alexander Graf <graf@amazon.com>

Thanks.

>> ---
>>   arch/x86/kvm/svm.c | 11 +++++++----
>>   1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 122788f..4bbf6fc 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -5283,10 +5283,13 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
>>       kvm_lapic_set_irr(vec, vcpu->arch.apic);
>>       smp_mb__after_atomic();
>>
>> -     if (avic_vcpu_is_running(vcpu))
>> -             wrmsrl(SVM_AVIC_DOORBELL,
>> -                    kvm_cpu_get_apicid(vcpu->cpu));
>> -     else
>> +     if (avic_vcpu_is_running(vcpu)) { > +           int cpuid = vcpu->cpu;
>> +
>> +             if (cpuid != get_cpu())
> 
> Tiny nitpick: What would keep you from checking vcpu->cpu directly here?

Nothing. Just coding style.

Thanks,
Suravee

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

* Re: [PATCH] svm/avic: Do not send AVIC doorbell to self
  2019-05-03 13:38 [PATCH] svm/avic: Do not send AVIC doorbell to self Suthikulpanit, Suravee
  2019-05-07 13:16 ` Graf, Alexander
@ 2019-05-20 12:56 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-05-20 12:56 UTC (permalink / raw)
  To: Suthikulpanit, Suravee, linux-kernel, kvm; +Cc: rkrcmar, joro

On 03/05/19 15:38, Suthikulpanit, Suravee wrote:
> AVIC doorbell is used to notify a running vCPU that interrupts
> has been injected into the vCPU AVIC backing page. Current logic
> checks only if a VCPU is running before sending a doorbell.
> However, the doorbell is not necessary if the destination
> CPU is itself.
> 
> Add logic to check currently running CPU before sending doorbell.
> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>  arch/x86/kvm/svm.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 122788f..4bbf6fc 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -5283,10 +5283,13 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
>  	kvm_lapic_set_irr(vec, vcpu->arch.apic);
>  	smp_mb__after_atomic();
>  
> -	if (avic_vcpu_is_running(vcpu))
> -		wrmsrl(SVM_AVIC_DOORBELL,
> -		       kvm_cpu_get_apicid(vcpu->cpu));
> -	else
> +	if (avic_vcpu_is_running(vcpu)) {
> +		int cpuid = vcpu->cpu;
> +
> +		if (cpuid != get_cpu())
> +			wrmsrl(SVM_AVIC_DOORBELL, kvm_cpu_get_apicid(cpuid));
> +		put_cpu();
> +	} else
>  		kvm_vcpu_wake_up(vcpu);
>  }
>  
> 

Queued, thanks.

Paolo

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

end of thread, other threads:[~2019-05-20 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 13:38 [PATCH] svm/avic: Do not send AVIC doorbell to self Suthikulpanit, Suravee
2019-05-07 13:16 ` Graf, Alexander
2019-05-14 15:52   ` Suthikulpanit, Suravee
2019-05-20 12:56 ` Paolo Bonzini

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