public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: pending interrupts are unlikely
@ 2020-03-13 12:40 Michael Mueller
  2020-03-13 12:48 ` David Hildenbrand
  2020-03-13 12:52 ` Christian Borntraeger
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Mueller @ 2020-03-13 12:40 UTC (permalink / raw)
  To: linux-s390, kvm
  Cc: borntraeger, frankja, david, cohuck, heiko.carstens, gor,
	Michael Mueller

A statistical analysis shows that in most cases when deliverable_irqs()
is called, no interrupts are pending. (see: early exit ratio)

The data was sampled during an iperf3 run over virtio_net
between one guest and the host.

deliverable_irqs()
        called = 3145123
           by kvm_s390_vcpu_has_irq() = 3005581 (95.56%)
              by kvm_arch_vcpu_runnable() = 3005578 (95.56%)
                 by kvm_s390_handle_wait() = 1219331 (38.76%)
                 by kvm_vcpu_check_block() = 2943565 (93.59%)
                    by kvm_cpu_block(1) = 2826431 (89.86%)
                    by kvm_cpu_block(2) = 117136 (3.72%)
                 by kvm_arch_dy_runnable() = 0 (0%)
              by kvm_arch_setup_async_pf() = 0 (0%)
              by handle_stop() = 0 (0%)
           by kvm_s390_deliver_pending_interrupt() = 139542 (4.43%)
              irqs_delivered = (0:15917 1:61810 2:1 3:0 4:0 x:0)
              irqs_pending = (0:15917 1:61722 2:86 3:1 4:0 x:0)
    early exit = 3021787 (96.07%)
  pending irqs = 123237 (3.91%)

Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
---
 arch/s390/kvm/interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 028167d6eacd..c34d62b4209e 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -369,7 +369,7 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
 	unsigned long active_mask;
 
 	active_mask = pending_irqs(vcpu);
-	if (!active_mask)
+	if (likely(!active_mask))
 		return 0;
 
 	if (psw_extint_disabled(vcpu))
-- 
2.17.0

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

* Re: [PATCH] KVM: s390: pending interrupts are unlikely
  2020-03-13 12:40 [PATCH] KVM: s390: pending interrupts are unlikely Michael Mueller
@ 2020-03-13 12:48 ` David Hildenbrand
  2020-03-13 12:52 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2020-03-13 12:48 UTC (permalink / raw)
  To: Michael Mueller, linux-s390, kvm
  Cc: borntraeger, frankja, cohuck, heiko.carstens, gor

On 13.03.20 13:40, Michael Mueller wrote:
> A statistical analysis shows that in most cases when deliverable_irqs()
> is called, no interrupts are pending. (see: early exit ratio)
> 
> The data was sampled during an iperf3 run over virtio_net
> between one guest and the host.
> 
> deliverable_irqs()
>         called = 3145123
>            by kvm_s390_vcpu_has_irq() = 3005581 (95.56%)
>               by kvm_arch_vcpu_runnable() = 3005578 (95.56%)
>                  by kvm_s390_handle_wait() = 1219331 (38.76%)
>                  by kvm_vcpu_check_block() = 2943565 (93.59%)
>                     by kvm_cpu_block(1) = 2826431 (89.86%)
>                     by kvm_cpu_block(2) = 117136 (3.72%)
>                  by kvm_arch_dy_runnable() = 0 (0%)
>               by kvm_arch_setup_async_pf() = 0 (0%)
>               by handle_stop() = 0 (0%)
>            by kvm_s390_deliver_pending_interrupt() = 139542 (4.43%)
>               irqs_delivered = (0:15917 1:61810 2:1 3:0 4:0 x:0)
>               irqs_pending = (0:15917 1:61722 2:86 3:1 4:0 x:0)
>     early exit = 3021787 (96.07%)
>   pending irqs = 123237 (3.91%)
> 
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 028167d6eacd..c34d62b4209e 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -369,7 +369,7 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
>  	unsigned long active_mask;
>  
>  	active_mask = pending_irqs(vcpu);
> -	if (!active_mask)
> +	if (likely(!active_mask))
>  		return 0;
>  
>  	if (psw_extint_disabled(vcpu))
> 

Is this change even observable in practice? Usually, we do have some
performance numbers backing such micro optimizations. But I guess it
will be fairly hard to get some meaning full numbers backing this ...

-- 
Thanks,

David / dhildenb

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

* Re: [PATCH] KVM: s390: pending interrupts are unlikely
  2020-03-13 12:40 [PATCH] KVM: s390: pending interrupts are unlikely Michael Mueller
  2020-03-13 12:48 ` David Hildenbrand
@ 2020-03-13 12:52 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2020-03-13 12:52 UTC (permalink / raw)
  To: Michael Mueller, linux-s390, kvm
  Cc: frankja, david, cohuck, heiko.carstens, gor



On 13.03.20 13:40, Michael Mueller wrote:
> A statistical analysis shows that in most cases when deliverable_irqs()
> is called, no interrupts are pending. (see: early exit ratio)
> 
> The data was sampled during an iperf3 run over virtio_net
> between one guest and the host.
> 
> deliverable_irqs()
>         called = 3145123
>            by kvm_s390_vcpu_has_irq() = 3005581 (95.56%)
>               by kvm_arch_vcpu_runnable() = 3005578 (95.56%)
>                  by kvm_s390_handle_wait() = 1219331 (38.76%)
>                  by kvm_vcpu_check_block() = 2943565 (93.59%)
>                     by kvm_cpu_block(1) = 2826431 (89.86%)
>                     by kvm_cpu_block(2) = 117136 (3.72%)
>                  by kvm_arch_dy_runnable() = 0 (0%)
>               by kvm_arch_setup_async_pf() = 0 (0%)
>               by handle_stop() = 0 (0%)
>            by kvm_s390_deliver_pending_interrupt() = 139542 (4.43%)
>               irqs_delivered = (0:15917 1:61810 2:1 3:0 4:0 x:0)
>               irqs_pending = (0:15917 1:61722 2:86 3:1 4:0 x:0)
>     early exit = 3021787 (96.07%)
>   pending irqs = 123237 (3.91%)
> 
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 028167d6eacd..c34d62b4209e 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -369,7 +369,7 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
>  	unsigned long active_mask;
>  
>  	active_mask = pending_irqs(vcpu);
> -	if (!active_mask)
> +	if (likely(!active_mask))

I have never been a fan of the likely/unlikely name. Instead this should have been
fastpath/slowpath. And with likely actually meaning fastpath this patch makes sense.

I guess it does not change the performance as the branch predictor is doing its job
most of the time. So I assume it would only be visible when there is contention in
the host.

Tentatively
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

will have a look at the code.

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

end of thread, other threads:[~2020-03-13 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-13 12:40 [PATCH] KVM: s390: pending interrupts are unlikely Michael Mueller
2020-03-13 12:48 ` David Hildenbrand
2020-03-13 12:52 ` Christian Borntraeger

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