From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, borntraeger@linux.ibm.com,
imbrenda@linux.ibm.com, pasic@linux.ibm.com
Subject: [PATCH v5 3/3] KVM: s390: Add opportunistic floating IRQ delivery
Date: Mon, 28 Sep 2026 12:30:57 +0000 [thread overview]
Message-ID: <20260928123639.34226-4-frankja@linux.ibm.com> (raw)
In-Reply-To: <20260928123639.34226-1-frankja@linux.ibm.com>
Try to distribute floating IRQs which haven't been taken by a VCPU yet
to sleeping VCPUs. This lowers the risk of floating IRQs not being
delivered.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
arch/s390/include/asm/kvm_host_s390.h | 1 +
arch/s390/kvm/s390/interrupt.c | 34 +++++++++++++++++++++++++++
arch/s390/kvm/s390/s390.c | 1 +
3 files changed, 36 insertions(+)
diff --git a/arch/s390/include/asm/kvm_host_s390.h b/arch/s390/include/asm/kvm_host_s390.h
index cd692f8fb764..a86863e621b7 100644
--- a/arch/s390/include/asm/kvm_host_s390.h
+++ b/arch/s390/include/asm/kvm_host_s390.h
@@ -412,6 +412,7 @@ struct kvm_vm_stat {
u64 gmap_shadow_r3_entry;
u64 gmap_shadow_sg_entry;
u64 gmap_shadow_pg_entry;
+ u64 inject_redist;
};
struct kvm_arch_memory_slot {
diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c
index 3c0e6216eee3..1b06775e581b 100644
--- a/arch/s390/kvm/s390/interrupt.c
+++ b/arch/s390/kvm/s390/interrupt.c
@@ -372,6 +372,38 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
return active_mask;
}
+static void distribute_float_irqs(struct kvm *kvm)
+{
+ struct kvm_vcpu *dst_vcpu;
+ int sigcpu, online_vcpus;
+
+ if (!READ_ONCE(kvm->arch.float_int.pending_irqs))
+ return;
+
+ online_vcpus = atomic_read(&kvm->online_vcpus);
+
+ /*
+ * Not too worried about synchronization for idle_mask. We
+ * might burn too many cycles but apart from that waking a
+ * vcpu is not harmful.
+ */
+ sigcpu = find_first_bit(kvm->arch.idle_mask, online_vcpus);
+
+ /* Well nobody's sleeping so someone will likely take the IRQ soon */
+ if (sigcpu == online_vcpus)
+ return;
+
+ do {
+ dst_vcpu = kvm_get_vcpu(kvm, sigcpu);
+ if (deliverable_irqs(dst_vcpu)) {
+ kvm->stat.inject_redist++;
+ kvm_s390_vcpu_wakeup(dst_vcpu);
+ break;
+ }
+ sigcpu = find_next_bit(kvm->arch.idle_mask, online_vcpus, ++sigcpu);
+ } while (sigcpu < online_vcpus);
+}
+
static void __set_cpu_idle(struct kvm_vcpu *vcpu)
{
kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
@@ -1294,6 +1326,8 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu)
if (!sltime)
return 0;
+ distribute_float_irqs(vcpu->kvm);
+
__set_cpu_idle(vcpu);
hrtimer_start(&vcpu->arch.ckc_timer, sltime, HRTIMER_MODE_REL);
VCPU_EVENT(vcpu, 4, "enabled wait: %llu ns", sltime);
diff --git a/arch/s390/kvm/s390/s390.c b/arch/s390/kvm/s390/s390.c
index efd77b9cd36c..252fde3abc9c 100644
--- a/arch/s390/kvm/s390/s390.c
+++ b/arch/s390/kvm/s390/s390.c
@@ -87,6 +87,7 @@ const struct kvm_stats_desc kvm_vm_stats_desc[] = {
STATS_DESC_COUNTER(VM, gmap_shadow_r3_entry),
STATS_DESC_COUNTER(VM, gmap_shadow_sg_entry),
STATS_DESC_COUNTER(VM, gmap_shadow_pg_entry),
+ STATS_DESC_COUNTER(VM, inject_redist),
};
const struct kvm_stats_header kvm_vm_stats_header = {
--
2.53.0
next prev parent reply other threads:[~2026-09-28 12:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 12:30 [PATCH v5 0/3] KVM: s390: Improve floating IRQ injection behavior Janosch Frank
2026-09-28 12:30 ` [PATCH v5 1/3] " Janosch Frank
2026-09-28 12:45 ` sashiko-bot
2026-09-28 12:30 ` [PATCH v5 2/3] KVM: s390: Kick PV cpus at the right time for service irqs Janosch Frank
2026-09-28 12:48 ` sashiko-bot
2026-09-28 12:30 ` Janosch Frank [this message]
2026-09-28 12:50 ` [PATCH v5 3/3] KVM: s390: Add opportunistic floating IRQ delivery sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260928123639.34226-4-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.