From: "Michael S. Tsirkin" <mst@redhat.com>
To: Parav Pandit <parav@nvidia.com>
Cc: Manivannan Sadhasivam <manisadhasivam.linux@gmail.com>,
"virtio-comment@lists.linux.dev" <virtio-comment@lists.linux.dev>,
"mie@igel.co.jp" <mie@igel.co.jp>
Subject: Re: MSI for Virtio PCI transport
Date: Tue, 25 Jun 2024 04:29:20 -0400 [thread overview]
Message-ID: <20240625042318-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <PH0PR12MB5481D98A78FB4650F9024E1CDCD52@PH0PR12MB5481.namprd12.prod.outlook.com>
On Tue, Jun 25, 2024 at 08:18:03AM +0000, Parav Pandit wrote:
>
> > From: Michael S. Tsirkin <mst@redhat.com>
> > Sent: Tuesday, June 25, 2024 1:40 PM
> >
> > On Tue, Jun 25, 2024 at 08:00:45AM +0000, Parav Pandit wrote:
> > >
> > > > From: Michael S. Tsirkin <mst@redhat.com>
> > > > Sent: Tuesday, June 25, 2024 1:25 PM
> > > > To: Parav Pandit <parav@nvidia.com>
> > > > Cc: Manivannan Sadhasivam <manisadhasivam.linux@gmail.com>; virtio-
> > > > comment@lists.linux.dev; mie@igel.co.jp
> > > > Subject: Re: MSI for Virtio PCI transport
> > > >
> > > > On Tue, Jun 25, 2024 at 06:18:46AM +0000, Parav Pandit wrote:
> > > > > > So MSI-X is clearly an optional feature which simple devices tend to
> > ignore.
> > > > > > But if both are supported, then obviously Virtio will make use
> > > > > > of MSI-X, but that's not the case here.
> > > > > >
> > > > > If both are supported, and required scale by the driver is <=32,
> > > > > driver can
> > > > choose MSI due to its lightweight nature.
> > > >
> > > > Unlikely, MSI vectors are tricky to mask and this is a problem for
> > > > interrupt balancing. So MSIX is better for performance even if the # of
> > vectors is low.
> > > Masking to my knowledge is not used by MSIX.
> >
> > There's a mask bit per vector, yes.
> >
> > > Didn't follow how MSIX helps with performance.
> >
> > Linux uses mask/change/unmask to balance interrupts between CPUs.
> > *That* is important for performance.
> Ah, I see, didn't know this.
> Frequently reprogramming the mask in device is expensive and also requires synchronization to not miss the interrupt.
> In case if you have pointer to the Linux code please share.
static inline void pci_msix_mask(struct msi_desc *desc)
{
desc->pci.msix_ctrl |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl);
/* Flush write to device */
readl(desc->pci.mask_base);
}
and
static inline void pci_write_msg_msix(struct msi_desc *desc, struct msi_msg *msg)
{
void __iomem *base = pci_msix_desc_addr(desc);
u32 ctrl = desc->pci.msix_ctrl;
bool unmasked = !(ctrl & PCI_MSIX_ENTRY_CTRL_MASKBIT);
if (desc->pci.msi_attrib.is_virtual)
return;
/*
* The specification mandates that the entry is masked
* when the message is modified:
*
* "If software changes the Address or Data value of an
* entry while the entry is unmasked, the result is
* undefined."
*/
if (unmasked)
pci_msix_write_vector_ctrl(desc, ctrl | PCI_MSIX_ENTRY_CTRL_MASKBIT);
writel(msg->address_lo, base + PCI_MSIX_ENTRY_LOWER_ADDR);
writel(msg->address_hi, base + PCI_MSIX_ENTRY_UPPER_ADDR);
writel(msg->data, base + PCI_MSIX_ENTRY_DATA);
if (unmasked)
pci_msix_write_vector_ctrl(desc, ctrl);
/* Ensure that the writes are visible in the device */
readl(base + PCI_MSIX_ENTRY_DATA);
}
both do this.
> A while back, I recollect seeing reprogramming done by the IOAPIC at the interrupt table level within the cpu (without involving the device) to forward to different cpu.
AFAIK MSI goes to lapic not to ioapic. I might be confused though.
> >
> >
> > > The benefit of MSI is it does not need to store addr+data pair per vector.
> >
> > The addr/data thing wasn't invented just to make hardware costs go up.
> >
> I am aware of it. :)
> I will let other non virtio forums finish their ongoing optimization work in this area to reduce hardware costs.
Absolutely.
--
MST
next prev parent reply other threads:[~2024-06-25 8:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 16:19 MSI for Virtio PCI transport Manivannan Sadhasivam
2024-06-25 4:09 ` Parav Pandit
2024-06-25 5:43 ` Manivannan Sadhasivam
2024-06-25 6:18 ` Parav Pandit
2024-06-25 7:55 ` Michael S. Tsirkin
2024-06-25 8:00 ` Parav Pandit
2024-06-25 8:09 ` Michael S. Tsirkin
2024-06-25 8:18 ` Parav Pandit
2024-06-25 8:29 ` Michael S. Tsirkin [this message]
2024-06-25 9:11 ` Manivannan Sadhasivam
2024-06-25 9:59 ` Parav Pandit
2024-06-25 7:52 ` Michael S. Tsirkin
2024-06-25 9:19 ` Manivannan Sadhasivam
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=20240625042318-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=manisadhasivam.linux@gmail.com \
--cc=mie@igel.co.jp \
--cc=parav@nvidia.com \
--cc=virtio-comment@lists.linux.dev \
/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