From: Dongli Zhang <dongli.zhang@oracle.com>
To: Chao Gao <chao.gao@intel.com>
Cc: x86@kernel.org, kvm@vger.kernel.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v2 1/1] x86/irq/i8259: Ack PIC vectors in the LAPIC ISR
Date: Wed, 25 Nov 2026 01:51:08 -0800 [thread overview]
Message-ID: <26a20220-c8f0-4c4c-8e26-142291336676@oracle.com> (raw)
In-Reply-To: <awABZ_BucR628XHj@intel.com>
Hi Chao,
On Fri, Nov 20, 2026 12:14:31AM -0800, Chao Gao wrote:
> On Thu, Nov 12, 2026 at 05: 06: 04PM +0000, Dongli Zhang wrote: >This is to fix
> a LAPIC ISR stall that can happen in a kdump kernel, but can >also happen in
> other scenarios. > >The issue can be intermittently reproduced in a QEMU/KVM
>
> On Thu, Nov 12, 2026 at 05:06:04PM +0000, Dongli Zhang wrote:
>>This is to fix a LAPIC ISR stall that can happen in a kdump kernel, but can
>>also happen in other scenarios.
>>
>>The issue can be intermittently reproduced in a QEMU/KVM guest when there
>>are large number of VMs on the same host.
>
> Does your production kernel include commit 1b558e14f3c1 ("x86/apic: Make the
> ISR clearing sane")? If so, can you reproduce this issue with it
> reverted? It looks to me that the one-pass ISR clearing doesn't clear all
> stale ISR/IRR bits.
>
> The changelog of that commit says
>
> 2) If interrupts are enabled, then the APIC propagates the IRR bit to the
> ISR and raises the interrupt in the CPU, which means that code _cannot_
> observe the ISR bit for any of those IRR bits.
>
> Your analysis shows a case where this doesn't hold, since the 8259A
> handler doesn't EOI the local APIC and the ISR bit stays set.
>
> You can certainly still reproduce it by injecting an interrupt manually
> after the ISR clearing. But I think the multi-pass scan may be enough for
> any practical case.
This commit came to my mind at first because I thought it was a bugfix.
When we ran into the issue, the guest VM kernel didn't have commit 1b558e14f3c1
("x86/apic: Make the ISR clearing sane").
The issue was hard to reproduce at first. I added printk calls in many places in
the guest kernel to narrow down when it occurred. At many points in
setup_local_APIC(), there were no pending IRR or ISR bits.
Based on my analysis, the issue happens if the virtio-net interrupt is delivered
before legacy interrupt handling is handed over from the 8259A to the IOAPIC.
Unfortunately, apic_clear_isr() is called before setup_IO_APIC().
https://lore.kernel.org/all/e4070a8b-fa4d-4ba1-a333-e7cf72da416e@oracle.com/
apic_bsp_setup()
-> setup_local_APIC()
-> apic_clear_isr() ---> clear pending irr/isr
-> ----> virtio-net interrupt delivered ...
-> setup_IO_APIC()
Thank you very much!
Dongli Zhang
>
>>
>>Device interrupts can use the PIC, IOAPIC, or MSI-X. Nowadays, most x86
>>device interrupts use MSI-X or the IOAPIC. However, the PIC handler does
>>not send a LAPIC EOI, even when the interrupt it handles has set a bit in
>>the LAPIC ISR.
>>
>>For example, suppose there is a QEMU/KVM guest using virtio-net.
>>
>>1. virtio-net is about to deliver vector 52 to CPU 2 (APIC ID 2), but the
>>guest suddenly panics on that CPU.
>>
>>2. The kdump kernel boots on APIC ID 2, which becomes CPU 0 in the new
>>kernel.
>>
>>3. Suppose delivery of the interrupt is delayed, so vector 52 has not
>>reached the CPU yet.
>>
>>4. On the new CPU 0, init_ISA_irqs() initially sets up the legacy IRQs to
>>use the PIC. Vector 52 maps to IRQ4, which is normally used by the serial
>>console.
>>
>>5. Before these legacy IRQs are handed over to the IOAPIC, suppose the
>>delayed vector 52 arrives through the LAPIC and sets its ISR bit.
>>
>>6. The new kernel handles it as PIC IRQ4. Since mask_and_ack_8259A()
>>does not send a LAPIC EOI, the ISR bit for vector 52 remains set.
>
prev parent reply other threads:[~2026-11-25 9:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 17:06 Dongli Zhang
2026-11-20 8:14 ` Chao Gao
2026-11-25 9:51 ` Dongli Zhang [this message]
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=26a20220-c8f0-4c4c-8e26-142291336676@oracle.com \
--to=dongli.zhang@oracle.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®