Re: [RFC PATCH] x86/irq: Drop redundant irq_{enter,exit}() calls from posted MSI handler
From: Sean Christopherson
Date: Wed Nov 04 2026 - 14:15:19 EST
On Tue, Jun 30, 2026, Sean Christopherson wrote:
> Drop the unnecessary irq_{enter,exit}() calls from the posted MSI handler,
> as the wrapper provided by DEFINE_IDTENTRY_SYSVEC() does all of the
> necessary bookkeeping (the x86 specific entry/exit code provides a
> superset of functionality).
>
> Note, in the series[1] that added DEFINE_IDTENTRY_SYSVEC(), the follow-up
> patches that actually use DEFINE_IDTENTRY_SYSVEC() drop all
> {entering,exiting}_irq() pairs (including entering_ack_irq()), where
> {entering,exiting}_irq() were little more than wrappers to
> irq_{enter,exit}().
>
> TODO: Explain what, if anything, can go wrong?
>
> Link: https://lore.kernel.org/all/20200521200513.656533920@xxxxxxxxxxxxx [1]
> Fixes: 1b03d82ba15e ("x86/irq: Install posted MSI notification handler")
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
>
> RFC purely because I have no idea what can go wrong, and I'd like to document
> any potential issues in the changelog. I'm confident in the change itself,
> or I've failed miserably at reading the code. :-)
>
> Found by inspection when looking at a bizarre code fetch from RIP=0 #PF that
> traces back to the irq_enter() (no reproducer for the #PF at this time). I
> don't know if the redundant bookkeeping contributed in any way, but the calls
> to irq_enter() and irq_exit() really stand out, because AFAICT, these are the
> *only* calls to those APIs in x86.
>
> arch/x86/kernel/irq.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
> index 30122f0b3af9..0ac63628a585 100644
> --- a/arch/x86/kernel/irq.c
> +++ b/arch/x86/kernel/irq.c
> @@ -430,7 +430,6 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msi_notification)
> /* Mark the handler active for intel_ack_posted_msi_irq() */
> __this_cpu_write(posted_msi_handler_active, true);
> inc_irq_stat(POSTED_MSI_NOTIFICATION);
> - irq_enter();
>
> /*
> * Loop only MAX_POSTED_MSI_COALESCING_LOOP - 1 times here to take
> @@ -456,7 +455,6 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msi_notification)
> handle_pending_pir(pid->pir, regs);
>
> apic_eoi();
> - irq_exit();
> __this_cpu_write(posted_msi_handler_active, false);
> set_irq_regs(old_regs);
> }
>
> base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
> --
> 2.55.0.rc0.799.gd6f94ed593-goog
Ping. I don't care terribly about landing the fix, but I would love input on
what, if anything, could go wrong.