Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: Don't kick vcpus for floating IRQs that are no longer pending
@ 2026-11-30  9:17 Christian Borntraeger
  2026-11-30  9:22 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Borntraeger @ 2026-11-30  9:17 UTC (permalink / raw)
  To: Janosch Frank, Claudio Imbrenda
  Cc: KVM, Christian Borntraeger, David Hildenbrand, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Sven Schnelle, linux-s390

kick_cpu_irq() searches for a vcpu that can take the injected floating
IRQ, starting with last_sleep_cpu, and, if it does not find one that
is suitable it wakes up all vcpus to avoid starvation.

For GISA interrupts, __inject_io() only sets the IPM bit and the
hardware may deliver the interrupt to a vcpu running in SIE before
kick_cpu_irq() looks at it. The IPM bit is then already clear, so
deliverable_irqs() returns 0 for every vcpu and all vcpus are woken up
for an interrupt that has already been delivered.

Whenever a candidate vcpu cannot take the IRQ, check whether the IRQ is
still pending for the VM at all and skip the kick if it is not. The
common case, where the last_sleep_cpu guess works, is not affected:
deliverable_irqs() has already looked at the pending IRQs then.

Measured with a 12 vcpu guest doing 4k random reads (4 jobs, iodepth
32) on a host NVMe attached as virtio-blk with 4 queues mapped to 2
iothreads, all QEMU threads pinned to vertical high/medium CPUs of a
shared LPAR (function profile via ftrace, so absolute times include
tracing overhead):

                                   before          after
  vcpu wakeups per kick            9.05            1.40
  kick_cpu_irq() avg               4.77us          0.41us
  eventfd_write() avg (irqfd)      3.67us          0.70us
  IOPS                             773k - 774k     806k - 809k
  host CPU per I/O                 7.7us           7.1 - 7.3us

virtio-net also shows benefit.

Fixes: 370b3a89cbd9 ("KVM: s390: Improve floating IRQ injection behavior")
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>

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

diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c
index 31a6074feffcb..df0f89b33147a 100644
--- a/arch/s390/kvm/s390/interrupt.c
+++ b/arch/s390/kvm/s390/interrupt.c
@@ -1963,6 +1963,17 @@ static void vcpu_intervention_kick(struct kvm_vcpu *vcpu, u64 type)
 	kvm_s390_vcpu_wakeup(vcpu);
 }
 
+/* Floating IRQs (including GISA IPM) pending for the VM */
+static unsigned long pending_float_irqs(struct kvm *kvm)
+{
+	struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
+	unsigned long pending = kvm->arch.float_int.pending_irqs;
+
+	if (gi->origin)
+		pending |= (unsigned long)gisa_get_ipm(gi->origin) << IRQ_PEND_IO_ISC_7;
+	return pending & ~kvm->arch.float_int.masked_irqs;
+}
+
 static void kick_cpu_irq(struct kvm *kvm, u64 type, u64 parm)
 {
 	struct kvm_vcpu *dst_vcpu;
@@ -1981,6 +1992,9 @@ static void kick_cpu_irq(struct kvm *kvm, u64 type, u64 parm)
 		if (!is_vcpu_stopped(dst_vcpu) &&
 		    deliverable_irqs(dst_vcpu) & irq_pend_mask)
 			break;
+		/* IRQ already delivered (e.g. via GISA), nobody to kick */
+		if (!(pending_float_irqs(kvm) & irq_pend_mask))
+			return;
 		/* avoid endless loops if all vcpus are stopped */
 		if (nr_tries++ >= online_vcpus) {
 			dst_vcpu = NULL;
-- 
2.56.1


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

* Re: [PATCH] KVM: s390: Don't kick vcpus for floating IRQs that are no longer pending
  2026-11-30  9:17 [PATCH] KVM: s390: Don't kick vcpus for floating IRQs that are no longer pending Christian Borntraeger
@ 2026-11-30  9:22 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30  9:22 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev

> kick_cpu_irq() searches for a vcpu that can take the injected floating
> IRQ, starting with last_sleep_cpu, and, if it does not find one that
> is suitable it wakes up all vcpus to avoid starvation.
> 
> For GISA interrupts, __inject_io() only sets the IPM bit and the
> hardware may deliver the interrupt to a vcpu running in SIE before
> kick_cpu_irq() looks at it. The IPM bit is then already clear, so
> deliverable_irqs() returns 0 for every vcpu and all vcpus are woken up
> for an interrupt that has already been delivered.
> 
> Whenever a candidate vcpu cannot take the IRQ, check whether the IRQ is
> still pending for the VM at all and skip the kick if it is not. The
> common case, where the last_sleep_cpu guess works, is not affected:
> deliverable_irqs() has already looked at the pending IRQs then.
> 
> [ ... ]
> 
> virtio-net also shows benefit.
> 
> Fixes: 370b3a89cbd9 ("KVM: s390: Improve floating IRQ injection behavior")
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130091704.1566209-1-borntraeger@linux.ibm.com?part=1

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

end of thread, other threads:[~2026-11-30  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  9:17 [PATCH] KVM: s390: Don't kick vcpus for floating IRQs that are no longer pending Christian Borntraeger
2026-11-30  9:22 ` sashiko-bot

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