From: Thomas Gleixner <tglx@linutronix.de>
To: "Dey, Megha" <megha.dey@intel.com>, LKML <linux-kernel@vger.kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>, Marc Zygnier <maz@kernel.org>,
Alex Williamson <alex.williamson@redhat.com>,
Kevin Tian <kevin.tian@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>, Ashok Raj <ashok.raj@intel.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Andrew Cooper <amc96@cam.ac.uk>, Juergen Gross <jgross@suse.com>,
linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [patch 09/10] PCI/MSI: Provide pci_msix_expand_vectors[_at]()
Date: Thu, 02 Dec 2021 11:16:39 +0100 [thread overview]
Message-ID: <871r2v71mg.ffs@tglx> (raw)
In-Reply-To: <7ad200fa-dda3-4932-cd23-ad6e79288ea4@intel.com>
Megha,
On Wed, Dec 01 2021 at 17:08, Megha Dey wrote:
> On 11/26/2021 5:25 PM, Thomas Gleixner wrote:
>> /**
>> + * pci_msix_expand_vectors_at - Expand MSI-X interrupts for a device
>> + *
>> + * @dev: PCI device to operate on
>> + * @at: Allocate at MSI-X index. If @at == PCI_MSI_EXPAND_AUTO
>> + * the function expands automatically after the last
> Not sure why some of these changes related to PCI_MSIX_EXPAND_AUTO and
> num_descs did not make it to the 'msi' branch.
> Is this intentional?
Yes, because I'm not happy about that magic.
>
> For instance, say:
> 1. Driver requests for 5 vectors:
> pci_enable_msix_range(dev, NULL, 5, 5)
> =>num_descs = 5
Driver should not use with pci_enable_msix_range() in the first
place. But yes, it got 5 vectors now.
> 2. Driver frees vectors at index 1,2:
> range = {1, 2, 2};
> pci_msi_teardown_msi_irqs(dev, range)
That function is not accessible by drivers for a reason.
> =>num_descs = 3; Current active vectors are at index: 0, 3, 4
> 3. Driver requests for 3 more vectors using the new API:
> pci_msix_expand_vectors(dev, 3)
> =>range.first = 3 => It will try to allocate index 3-5, but we already
> have 3,4 active?
> Ideally, we would want index 1,2 and 5 to be allocated for this request
> right?
>
> Could you please let me know what I am missing?
You're missing the real world use case. The above is fiction.
If a driver would release 1 and 2 then it should explicitely reallocate
1 and 2 and not let the core decide to magically allocate something.
If the driver wants three more after freeing 1, 2 then the core could
just allocate 5, 6, 7, and would still fulfil the callers request to
allocate three more, right?
And even if it just allocates one, then the caller still has to know the
index upfront. Why? Because it needs to know it in order to get the
Linux interrupt number via pci_irq_vector().
> Correspondingly, pci_free_msix_irq_vector(pdev, irq) frees all the
> allocated resources associated with MSI-X interrupt with Linux IRQ
> number 'irq'.
> I had issues when trying to dynamically allocate more than 1 interrupt
> because I didn't have a clean way to communicate to the driver what
> indexes were assigned in the current allocation.
If the driver is able to free a particular vector then it should exactly
know what it it doing and which index it is freeing. If it needs that
particular vector again, then it knows the index, right?
Let's look how MSI-X works in reality:
Each vector is associated to a particular function in the device. How
that association works is device dependent.
Some devices have hardwired associations, some allow the driver to
program the association in the device configuration and there is also a
combination of both.
So if the driver would free the vector for a particular functionality,
or not allocate it in the first place, then it exactly knows what it
freed and what it needs to allocate when it needs that functionality
(again).
What you are trying to create is a solution in search of a problem. You
cannot declare via a random allocation API how devices work. You neither
can fix the VFIO issue in a sensible way.
VFIO starts with vector #0 allocated. The guest then unmasks vector #50.
With your magic interface VFIO has to allocate 49 vectors and then free
48 of them again or just keep 48 around for nothing which defeats the
purpose of on demand allocation completely.
Thanks,
tglx
next prev parent reply other threads:[~2021-12-02 10:16 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 1:24 [patch 00/10] genirq/msi, PCI/MSI: Support for dynamic MSI-X vector expansion - Part 4 Thomas Gleixner
2021-11-27 1:24 ` [patch 01/10] genirq/msi: Add range argument to alloc/free MSI domain ops Thomas Gleixner
2021-11-27 1:24 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 02/10] genirq/msi: Add range argument to msi_domain_alloc/free_descs_locked() Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 03/10] genirq/msi: Make MSI descriptor alloc/free ready for range allocations Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-28 15:57 ` Marc Zyngier
2021-11-28 19:17 ` Thomas Gleixner
2021-11-29 17:28 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 05/10] genirq/msi: Add domain info flag MSI_FLAG_CAN_EXPAND Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 06/10] PCI/MSI: Use range in allocation path Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 08/10] PCI/MSI: Provide pci_msi_domain_supports_expand() Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 10/10] x86/apic/msi: Support MSI-X vector expansion Thomas Gleixner
2021-11-27 1:25 ` Thomas Gleixner
2021-11-27 1:24 ` [patch 00/10] genirq/msi, PCI/MSI: Support for dynamic MSI-X vector expansion - Part 4 Thomas Gleixner
2021-11-27 1:25 ` [patch 04/10] genirq/msi: Prepare MSI domain alloc/free for range irq allocation Thomas Gleixner
2021-11-27 1:24 ` Thomas Gleixner
2021-11-27 1:25 ` [patch 07/10] PCI/MSI: Make free related functions range based Thomas Gleixner
2021-11-27 1:24 ` Thomas Gleixner
2021-11-27 1:25 ` [patch 09/10] PCI/MSI: Provide pci_msix_expand_vectors[_at]() Thomas Gleixner
2021-11-27 1:24 ` Thomas Gleixner
2021-12-02 1:08 ` Dey, Megha
2021-12-02 10:16 ` Thomas Gleixner [this message]
2021-12-02 19:21 ` Raj, Ashok
2021-12-02 20:40 ` Thomas Gleixner
2021-12-03 0:45 ` Raj, Ashok
2021-12-03 12:29 ` 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=871r2v71mg.ffs@tglx \
--to=tglx@linutronix.de \
--cc=alex.williamson@redhat.com \
--cc=amc96@cam.ac.uk \
--cc=ashok.raj@intel.com \
--cc=helgaas@kernel.org \
--cc=jgg@nvidia.com \
--cc=jgross@suse.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=maz@kernel.org \
--cc=megha.dey@intel.com \
--cc=mpe@ellerman.id.au \
--cc=xen-devel@lists.xenproject.org \
/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