Re: [PATCH v8 3/3] KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject

From: Matthew Rosato

Date: Thu May 28 2026 - 12:32:17 EST


On 5/25/26 9:53 PM, Douglas Freimuth wrote:
> s390 needs a fast path for irq injection, and along those lines we
> introduce kvm_arch_set_irq_inatomic. Instead of placing all interrupts on
> the global work queue as it does today, this patch provides a fast path for
> irq injection.
>
> The inatomic fast path cannot lose control since it is running with
> interrupts disabled. This meant making the following changes that exist on
> the slow path today. First, the adapter_indicators page needs to be mapped
> since it is accessed with interrupts disabled, so we added map/unmap
> functions. Second, access to shared resources between the fast and slow
> paths needed to be changed from mutex and semaphores to spin_lock's.
> Finally, the memory allocation on the slow path utilizes GFP_KERNEL_ACCOUNT
> but we had to implement the fast path with GFP_ATOMIC allocation. Each of
> these enhancements were required to prevent blocking on the fast inject
> path.
>
> Fencing of Fast Inject in Secure Execution environments is enabled in the
> patch series by not mapping adapter indicator pages. In Secure Execution
> environments the path of execution available before this patch is followed.
>
> Statistical counters have been added to enable analysis of irq injection on
> the fast path and slow path including io_390_inatomic, io_flic_inject_airq,
> io_set_adapter_int and io_390_inatomic_adapter_masked_or_coalesced.

That's a mouthful. And it also doesn't include suppressed interrupts.

How about something like _no_inject to imply that interrupt was
delivered via the adapter interrupt bits without needing to inject the
irq.

[...]

> @@ -2719,25 +2728,41 @@ static int kvm_s390_inject_airq(struct kvm *kvm,
> .parm = 0,
> .parm64 = isc_to_int_word(adapter->isc),
> };
> + struct kvm_s390_interrupt_info *inti;
> + unsigned long flags;
> +
> int ret = 0;
>
> - if (!test_kvm_facility(kvm, 72) || !adapter->suppressible)
> - return kvm_s390_inject_vm(kvm, &s390int);
> + inti = kzalloc_obj(*inti, GFP_KERNEL_ACCOUNT);
> + if (!inti)
> + return -ENOMEM;
>
> - mutex_lock(&fi->ais_lock);
> + if (!test_kvm_facility(kvm, 72) || !adapter->suppressible) {
> + ret = kvm_s390_inject_vm(kvm, &s390int, inti);
> + if (ret)
> + kfree(inti);
> + return ret;
> + }
> +
> + spin_lock_irqsave(&fi->ais_lock, flags);
> if (fi->nimm & AIS_MODE_MASK(adapter->isc)) {
> trace_kvm_s390_airq_suppressed(adapter->id, adapter->isc);
> - goto out;
> + spin_unlock_irqrestore(&fi->ais_lock, flags);
> + kfree(inti);

I suggested adding this to the same counter as masked and coalesced, and
I still think you should: so add a _no_inject++ here

Otherwise, LGTM -- please send a v9 with this and the other small things
I mentioned on the other 2 patches.