All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] small optimizations for exitless interrupts
@ 2018-02-13 12:28 Christian Borntraeger
  2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christian Borntraeger @ 2018-02-13 12:28 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	David Hildenbrand, Michael Mueller, Halil Pasic

Some small optimizations for the exitless interrupts

Christian Borntraeger (2):
  KVM: s390: optimize wakeup for exitless interrupts
  KVM: s390: do not set intervention requests for GISA interrupts

 arch/s390/kvm/interrupt.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

-- 
2.14.3

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

* [PATCH 1/2] KVM: s390: optimize wakeup for exitless interrupts
  2018-02-13 12:28 [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
@ 2018-02-13 12:28 ` Christian Borntraeger
  2018-02-13 13:40   ` David Hildenbrand
  2018-02-13 15:46   ` Cornelia Huck
  2018-02-13 12:28 ` [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts Christian Borntraeger
  2018-02-14  8:38 ` [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
  2 siblings, 2 replies; 8+ messages in thread
From: Christian Borntraeger @ 2018-02-13 12:28 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	David Hildenbrand, Michael Mueller, Halil Pasic

For interrupt injection of floating interrupts we queue the interrupt
either in the GISA or in the floating  interrupt list. The first CPU
that looks at these data structures - either in KVM code or hardware
will then deliver that interrupt. To minimize latency we also:
-a: choose a VCPU to deliver that interrupt. We prefer idle CPUs
-b: we wake up the host thread that runs the VCPU
-c: set an I/O intervention bit for that CPU so that it exits guest
    context as soon as the PSW I/O mask is enabled
This will make sure that this CPU will execute the interrupt delivery
code of KVM very soon.

We can now optimize the injection case if we have exitless interrupts.
The wakeup is still necessary in case the target CPU sleeps. We can
avoid the I/O intervention request bit though. Whenever this
intervention request would be handled, the hardware could also directly
inject the interrupt on that CPU, no need to go through the interrupt
injection loop of KVM.

Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/interrupt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index aabf46f5f883..337a69bc04db 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -1701,7 +1701,8 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
 		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_STOP_INT);
 		break;
 	case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
-		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
+		if (!(type & KVM_S390_INT_IO_AI_MASK && kvm->arch.gisa))
+			kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
 		break;
 	default:
 		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_EXT_INT);
-- 
2.14.3

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

* [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts
  2018-02-13 12:28 [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
  2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
@ 2018-02-13 12:28 ` Christian Borntraeger
  2018-02-13 13:42   ` David Hildenbrand
  2018-02-13 15:48   ` Cornelia Huck
  2018-02-14  8:38 ` [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
  2 siblings, 2 replies; 8+ messages in thread
From: Christian Borntraeger @ 2018-02-13 12:28 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, linux-s390,
	David Hildenbrand, Michael Mueller, Halil Pasic

If GISA is available, we do not have to kick CPUs out of SIE to deliver
interrupts. The hardware can deliver such interrupts while running.

Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/interrupt.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 337a69bc04db..e399495001ca 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -236,10 +236,15 @@ static inline int kvm_s390_gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gis
 	return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
 }
 
-static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
+static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu)
 {
 	return vcpu->kvm->arch.float_int.pending_irqs |
-		vcpu->arch.local_int.pending_irqs |
+		vcpu->arch.local_int.pending_irqs;
+}
+
+static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
+{
+	return pending_irqs_no_gisa(vcpu) |
 		kvm_s390_gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7;
 }
 
@@ -337,7 +342,7 @@ static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
 
 static void set_intercept_indicators_io(struct kvm_vcpu *vcpu)
 {
-	if (!(pending_irqs(vcpu) & IRQ_PEND_IO_MASK))
+	if (!(pending_irqs_no_gisa(vcpu) & IRQ_PEND_IO_MASK))
 		return;
 	else if (psw_ioint_disabled(vcpu))
 		kvm_s390_set_cpuflags(vcpu, CPUSTAT_IO_INT);
-- 
2.14.3

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

* Re: [PATCH 1/2] KVM: s390: optimize wakeup for exitless interrupts
  2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
@ 2018-02-13 13:40   ` David Hildenbrand
  2018-02-13 15:46   ` Cornelia Huck
  1 sibling, 0 replies; 8+ messages in thread
From: David Hildenbrand @ 2018-02-13 13:40 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, linux-s390, Michael Mueller, Halil Pasic

On 13.02.2018 13:28, Christian Borntraeger wrote:
> For interrupt injection of floating interrupts we queue the interrupt
> either in the GISA or in the floating  interrupt list. The first CPU
> that looks at these data structures - either in KVM code or hardware
> will then deliver that interrupt. To minimize latency we also:
> -a: choose a VCPU to deliver that interrupt. We prefer idle CPUs
> -b: we wake up the host thread that runs the VCPU
> -c: set an I/O intervention bit for that CPU so that it exits guest
>     context as soon as the PSW I/O mask is enabled
> This will make sure that this CPU will execute the interrupt delivery
> code of KVM very soon.
> 
> We can now optimize the injection case if we have exitless interrupts.
> The wakeup is still necessary in case the target CPU sleeps. We can
> avoid the I/O intervention request bit though. Whenever this
> intervention request would be handled, the hardware could also directly
> inject the interrupt on that CPU, no need to go through the interrupt
> injection loop of KVM.
> 
> Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
> Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index aabf46f5f883..337a69bc04db 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -1701,7 +1701,8 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
>  		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_STOP_INT);
>  		break;
>  	case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
> -		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
> +		if (!(type & KVM_S390_INT_IO_AI_MASK && kvm->arch.gisa))
> +			kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
>  		break;
>  	default:
>  		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_EXT_INT);
> 

Looks sane to me

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

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

* Re: [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts
  2018-02-13 12:28 ` [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts Christian Borntraeger
@ 2018-02-13 13:42   ` David Hildenbrand
  2018-02-13 15:48   ` Cornelia Huck
  1 sibling, 0 replies; 8+ messages in thread
From: David Hildenbrand @ 2018-02-13 13:42 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, linux-s390, Michael Mueller, Halil Pasic

On 13.02.2018 13:28, Christian Borntraeger wrote:
> If GISA is available, we do not have to kick CPUs out of SIE to deliver
> interrupts. The hardware can deliver such interrupts while running.
> 
> Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 337a69bc04db..e399495001ca 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -236,10 +236,15 @@ static inline int kvm_s390_gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gis
>  	return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
>  }
>  
> -static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
> +static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu)
>  {
>  	return vcpu->kvm->arch.float_int.pending_irqs |
> -		vcpu->arch.local_int.pending_irqs |
> +		vcpu->arch.local_int.pending_irqs;
> +}
> +
> +static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
> +{
> +	return pending_irqs_no_gisa(vcpu) |
>  		kvm_s390_gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7;
>  }
>  
> @@ -337,7 +342,7 @@ static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
>  
>  static void set_intercept_indicators_io(struct kvm_vcpu *vcpu)
>  {
> -	if (!(pending_irqs(vcpu) & IRQ_PEND_IO_MASK))
> +	if (!(pending_irqs_no_gisa(vcpu) & IRQ_PEND_IO_MASK))
>  		return;
>  	else if (psw_ioint_disabled(vcpu))
>  		kvm_s390_set_cpuflags(vcpu, CPUSTAT_IO_INT);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

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

* Re: [PATCH 1/2] KVM: s390: optimize wakeup for exitless interrupts
  2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
  2018-02-13 13:40   ` David Hildenbrand
@ 2018-02-13 15:46   ` Cornelia Huck
  1 sibling, 0 replies; 8+ messages in thread
From: Cornelia Huck @ 2018-02-13 15:46 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, linux-s390, David Hildenbrand,
	Michael Mueller, Halil Pasic

On Tue, 13 Feb 2018 12:28:57 +0000
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> For interrupt injection of floating interrupts we queue the interrupt
> either in the GISA or in the floating  interrupt list. The first CPU
> that looks at these data structures - either in KVM code or hardware
> will then deliver that interrupt. To minimize latency we also:
> -a: choose a VCPU to deliver that interrupt. We prefer idle CPUs
> -b: we wake up the host thread that runs the VCPU
> -c: set an I/O intervention bit for that CPU so that it exits guest
>     context as soon as the PSW I/O mask is enabled
> This will make sure that this CPU will execute the interrupt delivery
> code of KVM very soon.
> 
> We can now optimize the injection case if we have exitless interrupts.
> The wakeup is still necessary in case the target CPU sleeps. We can
> avoid the I/O intervention request bit though. Whenever this
> intervention request would be handled, the hardware could also directly
> inject the interrupt on that CPU, no need to go through the interrupt
> injection loop of KVM.
> 
> Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
> Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index aabf46f5f883..337a69bc04db 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -1701,7 +1701,8 @@ static void __floating_irq_kick(struct kvm *kvm, u64 type)
>  		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_STOP_INT);
>  		break;
>  	case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
> -		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
> +		if (!(type & KVM_S390_INT_IO_AI_MASK && kvm->arch.gisa))
> +			kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT);
>  		break;
>  	default:
>  		kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_EXT_INT);

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

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

* Re: [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts
  2018-02-13 12:28 ` [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts Christian Borntraeger
  2018-02-13 13:42   ` David Hildenbrand
@ 2018-02-13 15:48   ` Cornelia Huck
  1 sibling, 0 replies; 8+ messages in thread
From: Cornelia Huck @ 2018-02-13 15:48 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, linux-s390, David Hildenbrand,
	Michael Mueller, Halil Pasic

On Tue, 13 Feb 2018 12:28:58 +0000
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> If GISA is available, we do not have to kick CPUs out of SIE to deliver
> interrupts. The hardware can deliver such interrupts while running.
> 
> Cc: Michael Mueller <mimu@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/kvm/interrupt.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

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

* Re: [PATCH 0/2] small optimizations for exitless interrupts
  2018-02-13 12:28 [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
  2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
  2018-02-13 12:28 ` [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts Christian Borntraeger
@ 2018-02-14  8:38 ` Christian Borntraeger
  2 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2018-02-14  8:38 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, linux-s390, David Hildenbrand,
	Michael Mueller, Halil Pasic

queued both patches for Master (4.16)

On 02/13/2018 01:28 PM, Christian Borntraeger wrote:
> Some small optimizations for the exitless interrupts
> 
> Christian Borntraeger (2):
>   KVM: s390: optimize wakeup for exitless interrupts
>   KVM: s390: do not set intervention requests for GISA interrupts
> 
>  arch/s390/kvm/interrupt.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 

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

end of thread, other threads:[~2018-02-14  8:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 12:28 [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger
2018-02-13 12:28 ` [PATCH 1/2] KVM: s390: optimize wakeup " Christian Borntraeger
2018-02-13 13:40   ` David Hildenbrand
2018-02-13 15:46   ` Cornelia Huck
2018-02-13 12:28 ` [PATCH 2/2] KVM: s390: do not set intervention requests for GISA interrupts Christian Borntraeger
2018-02-13 13:42   ` David Hildenbrand
2018-02-13 15:48   ` Cornelia Huck
2018-02-14  8:38 ` [PATCH 0/2] small optimizations for exitless interrupts Christian Borntraeger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.