RE: [PATCH V4 05/11] vfio/pci: Use xarray for interrupt context storage

From: Tian, Kevin
Date: Fri Apr 28 2023 - 02:35:44 EST


> From: Chatre, Reinette <reinette.chatre@xxxxxxxxx>
> Sent: Friday, April 28, 2023 1:36 AM
>
> Interrupt context is statically allocated at the time interrupts
> are allocated. Following allocation, the context is managed by
> directly accessing the elements of the array using the vector
> as index. The storage is released when interrupts are disabled.
>
> It is possible to dynamically allocate a single MSI-X interrupt
> after MSI-X is enabled. A dynamic storage for interrupt context
> is needed to support this. Replace the interrupt context array with an
> xarray (similar to what the core uses as store for MSI descriptors)
> that can support the dynamic expansion while maintaining the
> custom that uses the vector as index.
>
> With a dynamic storage it is no longer required to pre-allocate
> interrupt contexts at the time the interrupts are allocated.
> MSI and MSI-X interrupt contexts are only used when interrupts are
> enabled. Their allocation can thus be delayed until interrupt enabling.
> Only enabled interrupts will have associated interrupt contexts.
> Whether an interrupt has been allocated (a Linux irq number exists
> for it) becomes the criteria for whether an interrupt can be enabled.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>