Re: [PATCH v2] PCI/MSI: Avoid torn updates to MSI pairs

From: Evan Green
Date: Wed Jan 29 2020 - 17:53:58 EST


On Wed, Jan 29, 2020 at 1:01 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> Evan,
>
> Evan Green <evgreen@xxxxxxxxxxxx> writes:
> > On Tue, Jan 28, 2020 at 2:48 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> >>
> >> Bah. I'm sure I looked at that call chain, noticed the double vector
> >> lock and then forgot. Delta patch below.
> >
> > It's working well with the delta patch, been running for about an hour
> > with no issues.
>
> thanks for the info and for testing!
>
> Could you please add some instrumentation to see how often this stuff
> actually triggers spurious interrupts?

In about 10 minutes of this script running, I got 142 hits. My script
can toggle the HT cpus on and off about twice per second.
Here's my diff (sorry it's mangled by gmail). If you're looking for
something else, let me know, or I can run a patch.

diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index 90baf2c66bd40..f9c46fc30d658 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -61,6 +61,8 @@ static void irq_msi_update_msg(struct irq_data
*irqd, struct irq_cfg *cfg)
irq_data_get_irq_chip(irqd)->irq_write_msi_msg(irqd, msg);
}

+int evanpending;
+
static int
msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force)
{
@@ -155,8 +157,10 @@ msi_set_affinity(struct irq_data *irqd, const
struct cpumask *mask, bool force)

unlock_vector_lock();

- if (pending)
+ if (pending) {
+ printk("EVAN pending %d", ++evanpending);
irq_data_get_irq_chip(irqd)->irq_retrigger(irqd);
+ }

return ret;
}

-Evan