mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hogan Wang <hogan.wang@huawei.com>
To: <tglx@linutronix.de>, <x86@kernel.org>,
	<dave.hansen@linux.intel.com>, <kvm@vger.kernel.org>,
	<alex.williamson@redhat.com>
Cc: <weidong.huang@huawei.com>, <yechuan@huawei.com>,
	<hogan.wang@huawei.com>, <wangxinxin.wang@huawei.com>,
	<jianjay.zhou@huawei.com>, <wangjie88@huawei.com>,
	<maz@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/irq: Plug vector setup race
Date: Fri, 1 Aug 2025 22:56:33 +0800	[thread overview]
Message-ID: <20250801145633.2412-1-hogan.wang@huawei.com> (raw)
In-Reply-To: <87a54kil52.ffs@tglx>

> On Thu, Jul 24 2025 at 12:49, Thomas Gleixner wrote:
> 

Thank you very much for your professional, friendly, and detailed response.
Based on the clear modification suggestions you provided, I conducted
retesting and validation using the following methods:

1) Start a virtual machine with 192U384G specification, and configure
   one VirtioNet network card and one VirtioSCSI disk.
2) After the virtual machine starts successfully, execute the following
   script inside the virtual machine. The interrupt number 30 is the
   VirtioNet MSI-x interrupt.

for((;;))
    do (for((i=0;i<192;i++))
	    do echo $i > /proc/irq/30/smp_affinity_list
		sleep 0.1
	done)
done

After a 7x24-hour test, no error logs of the type "No irq handler for
vector" were found, I believe this issue should have already been
resolved. 

As you said, this fix cannot solve the problem of lost interrupts.

I believe an effective solution to the issue of lost interrupts
might be to modify the vifo module to avoid un-plug/plug irq,
and instead use a more lightweight method to switch interrupt
modes. Just like:

vfio_irq_handler()
	if kvm_mode
		vfio_send_eventfd(kvm_irq_fd);
	else
		vfio_send_eventfd(qemu_irq_fd);

However, this will bring about some troubles:
1) The kvm_mode variable should be protected, leading to performance loss. 
2) The VFIO interface requires the passing of two eventfds. 
3) Add another interface to implement mode switching. 

Do you have a better solution to fix this interrupt loss issue? 
	
There is a question that has been troubling me: Why are interrupts
still reported after they have been masked and the interrupt remapping
table entries have been disabled? Is this interrupt cached somewhere?

> Hogan!
> 
> > Hogan reported a vector setup race, which overwrites the interrupt 
> > descriptor in the per CPU vector array resulting in a disfunctional device.
> >
> > CPU0				CPU1
> > 				interrupt is raised in APIC IRR
> > 				but not handled
> >   free_irq()
> >     per_cpu(vector_irq, CPU1)[vector] = VECTOR_SHUTDOWN;
> >
> >   request_irq()			common_interrupt()
> >   				  d = this_cpu_read(vector_irq[vector]);
> >
> >     per_cpu(vector_irq, CPU1)[vector] = desc;
> >
> >     				  if (d == VECTOR_SHUTDOWN)
> > 				    this_cpu_write(vector_irq[vector], VECTOR_UNUSED);
> >
> > free_irq() cannot observe the pending vector in the CPU1 APIC as there 
> > is no way to query the remote CPUs APIC IRR.
> >
> > This requires that request_irq() uses the same vector/CPU as the one 
> > which was freed, but this also can be triggered by a spurious interrupt.
> >
> > Prevent this by reevaluating vector_irq under the vector lock, which 
> > is held by the interrupt activation code when vector_irq is updated.
> 
> Does this fix your problem?

Thanks,

		Hogan
-- 
2.45.1

  reply	other threads:[~2025-08-01 14:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <draft-87ikjhrhhh.ffs@tglx>
2025-07-31 12:45 ` Thomas Gleixner
2025-08-01 14:56   ` Hogan Wang [this message]
2025-08-02 11:54     ` Thomas Gleixner
2025-08-02 12:18 ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2025-08-02 20:08 ` tip-bot2 for Thomas Gleixner
2025-08-04 22:42 ` tip-bot2 for Thomas Gleixner

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=20250801145633.2412-1-hogan.wang@huawei.com \
    --to=hogan.wang@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangjie88@huawei.com \
    --cc=wangxinxin.wang@huawei.com \
    --cc=weidong.huang@huawei.com \
    --cc=x86@kernel.org \
    --cc=yechuan@huawei.com \
    /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®