Re: [PATCH] x86/apic: Add retry mechanism to add_pin_to_irq_node()

From: Thomas Gleixner
Date: Mon Jul 29 2024 - 12:13:50 EST


On Mon, Jul 29 2024 at 07:06, Breno Leitao wrote:
> I've been running some experiments with failslab fault injector running
> to detect a different problem, and the machine always crash with the
> following stack:
>
> can not alloc irq_pin_list (-1,0,20)
> Kernel panic - not syncing: IO-APIC: failed to add irq-pin. Can not proceed
>
> Call Trace:
> panic
> _printk
> panic_smp_self_stop
> rcu_is_watching
> intel_irq_remapping_free

This completely lacks context. When does this happen? What's the system
state? What has intel_irq_remapping_free() to do with the allocation path?

> This happens because add_pin_to_irq_node() function would panic if
> adding a pin to an IRQ failed due to -ENOMEM (which was injected by
> failslab fault injector). I've been running with this patch in my test
> cases in order to be able to pick real bugs, and I thought it might be a
> good idea to have it upstream also, so, other people trying to find real
> bugs don't stumble upon this one. Also, this makes sense in a real
> world(?), when retrying a few times might be better than just
> panicking.

While it seems to make sense, the reality is that this is mostly early
boot code. If there is a real world memory allocation failure during
early boot then retries will not help at all.

> Introduce a retry mechanism that attempts to add the pin up to 3 times
> before giving up and panicking. This should improve the robustness of
> the IO-APIC code in the face of transient errors.

I'm absolutely not convinced by this loop heuristic. That's just a bad
hack.

Thanks,

tglx