Re: [RFC PATCH v2] gen/irq: Change the way to differentiate between managed and unmanaged interrupts by bitmap

From: Thomas Gleixner
Date: Fri Nov 23 2018 - 13:28:59 EST


Dou,

On Sat, 10 Nov 2018, Dou Liyang wrote:

sorry for late reply. Travel, conferences ....

> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -673,14 +674,17 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
> const struct irq_affinity *affd)
> {
> struct cpumask *curmsk, *masks = NULL;
> + DECLARE_BITMAP(managed, nvec);

This is not working as it creates a variable length array (VLA). We just
got rid of all VLAs in the kernel and the compiler will catch this and
complain.

> struct msi_desc *entry;
> int ret, i;
>
> + memset(managed, 0, sizeof(managed));
> if (affd)
> - masks = irq_create_affinity_masks(nvec, affd);
> + masks = irq_create_affinity_masks(nvec, affd, managed);

So rather than changing the world and everything by adding new arguments,
what about the following:

-struct cpumask *irq_create_affinity_masks(int nvec, const struct irq_affinity *affd);
+struct irq_affinity_desc * irq_create_affinity_masks(int nvec, struct irq_affinity *affd);

struct irq_affinity_desc {
struct cpumask mask;
unsigned long flags;
};

or something like that. Let irq_create_affinity_masks() allocate an array
of those and store the information in the flags field. In the allocation
functions just replace the cpumask pointer with a irq_affinity_desc pointer
and hand that through to the irqdesc core, where you can evaluate the
flags. Way less things to modify and the data structure allows to expand
this in the future without touching all the functions ever again.

Can you please work against the tip irq/core branch as that has already
other changes in the affinity spreading code queued?

Thanks,

tglx