net/mlx5: Fix mlx5_get_vector_affinity function
Subsystems (3)
Quoted 10 lines · Israel Rukshin
Adding the vector offset when calling to
mlx5_vector2eqn()is wrong. This is becausemlx5_vector2eqn()checks if EQ index is equal to vector number and the fact that the internal completion vectors that mlx5 allocates don't get an EQ index.The second problem here is that using
effective_affinity_maskgives the same CPU for different vectors.
This leads to unmapped queues when calling it fromblk_mq_rdma_map_queues(). This doesn't happen when usingaffinity_hintmask.
Except that affinity_hint is only defined if SMP is enabled. Without:
include/linux/mlx5/driver.h: In function ‘mlx5_get_vector_affinity_hint’:include/linux/mlx5/driver.h:1299:13: error:
‘struct irq_desc’ has no member named ‘affinity_hint’
Note that this is the only use of affinity_hint outside kernel/irq. Don't other drivers have similar problems ?
Guenter
Quoted 58 lines
Fixes 2572cf57d75a ("mlx5: fix mlx5_get_vector_affinity to start from completion vector 0")Fixes 05e0cc84e00c ("net/mlx5: Fix get vector affinity helper function")Signed-off-by Israel Rukshin <[email protected]>Reviewed-by Max Gurtovoy <[email protected]>Reviewed-by Sagi Grimberg <[email protected]>--- drivers/infiniband/hw/mlx5/main.c | 2 +- include/linux/mlx5/driver.h | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-)drivers/infiniband/hw/mlx5/main.c +1
-1@@ -4757,7 +4757,7 @@ mlx5_ib_get_vector_affinity(struct ib_device *ibdev, int comp_vector) {struct mlx5_ib_dev *dev =to_mdev (ibdev); -return mlx5_get_vector_affinity (dev->mdev, comp_vector); +return mlx5_get_vector_affinity_hint (dev->mdev, comp_vector); }/* The mlx5_ib_multiport_mutex should be held when calling this function */ include/linux/mlx5/driver.h +3
-9@@ -1284,25 +1284,19 @@ enum { };static inline const struct cpumask * -mlx5_get_vector_affinity (struct mlx5_core_dev *dev,int vector) +mlx5_get_vector_affinity_hint (struct mlx5_core_dev *dev,int vector) { -const struct cpumask *mask;struct irq_desc *desc;unsigned int irq;int eqn;int err; - err =mlx5_vector2eqn (dev,MLX5_EQ_VEC_COMP_BASE + vector, &eqn, &irq); + err =mlx5_vector2eqn (dev, vector, &eqn, &irq);if (err)return NULL ; desc =irq_to_desc (irq); -#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK - mask =irq_data_get_effective_affinity_mask (&desc->irq_data); -#else - mask = desc->irq_common_data.affinity; -#endif -return mask; +return desc->affinity_hint; }#endif /* MLX5_DRIVER_H */ Signature · 1 line
2.7.4
Thomas Gleixner
NAKQuoted 11 lines · Guenter Roeck
Quoted 10 lines · Israel Rukshin
Adding the vector offset when calling to
mlx5_vector2eqn()is wrong. This is becausemlx5_vector2eqn()checks if EQ index is equal to vector number and the fact that the internal completion vectors that mlx5 allocates don't get an EQ index.The second problem here is that using
effective_affinity_maskgives the same CPU for different vectors.
This leads to unmapped queues when calling it fromblk_mq_rdma_map_queues(). This doesn't happen when usingaffinity_hintmask.
Quoted 8 lines
Except that
affinity_hintis only defined if SMP is enabled. Without:
include/linux/mlx5/driver.h: In function ‘mlx5_get_vector_affinity_hint’:include/linux/mlx5/driver.h:1299:13: error:
‘struct irq_desc’ has no member named ‘affinity_hint’Note that this is the only use of
affinity_hintoutside kernel/irq. Don't other drivers have similar problems ?
Aside of that.
Quoted 15 lines
Quoted 15 lines
static inline const struct cpumask *
(quoted diff) +2
-3-mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector) +mlx5_get_vector_affinity_hint(struct mlx5_core_dev *dev, int vector) { - const struct cpumask *mask; struct irq_desc *desc; unsigned int irq; int eqn; int err; - err = mlx5_vector2eqn(dev, MLX5_EQ_VEC_COMP_BASE + vector, &eqn, &irq); + err = mlx5_vector2eqn(dev, vector, &eqn, &irq); if (err) return NULL;
Quoted 8 lines
Review
Quoted 8 lines
(quoted diff) +1
-6desc = irq_to_desc(irq); -#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK - mask = irq_data_get_effective_affinity_mask(&desc->irq_data); -#else - mask = desc->irq_common_data.affinity; -#endif - return mask; + return desc->affinity_hint;
NAK.
Nothing in regular device drivers is supposed to ever fiddle with struct irq_desc. The existing code is already a violation of that rule and needs to be fixed, but not in that way.
The logic here is completely screwed. affinity_hint is set by the driver, so the driver already knows what it is. If the driver does not set it, then the thing is NULL.
Thanks,
tglx
Quoted 11 lines · Thomas Gleixner
Quoted 7 lines · Guenter Roeck
Review
Quoted 7 lines
(quoted diff) +1
-6-#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK - mask = irq_data_get_effective_affinity_mask(&desc->irq_data); -#else - mask = desc->irq_common_data.affinity; -#endif - return mask; + return desc->affinity_hint;NAK.
Quoted 7 lines
Nothing in regular device drivers is supposed to ever fiddle with struct
irq_desc. The existing code is already a violation of that rule and needs to be fixed, but not in that way.The logic here is completely screwed.
affinity_hintis set by the driver, so the driver already knows what it is. If the driver does not set it, then the thing is NULL.
And this completely insane fiddling with irq_desc is in MLX4 as well. Dammit, why can't people respect subsytem boundaries and just fiddle in everything just because they can? If there is something missing at the core level then please talk to the maintainers instead of hacking utter crap into your driver.
Yours grumpy
tglx
Quoted 39 lines · Thomas Gleixner
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Israel Rukshin
Adding the vector offset when calling to
mlx5_vector2eqn()is wrong. This is becausemlx5_vector2eqn()checks if EQ index is equal to vector number and the fact that the internal completion vectors that mlx5 allocates don't get an EQ index.The second problem here is that using
effective_affinity_maskgives the same CPU for different vectors.
This leads to unmapped queues when calling it fromblk_mq_rdma_map_queues(). This doesn't happen when usingaffinity_hintmask.Quoted 8 lines
Except that
affinity_hintis only defined if SMP is enabled. Without:
include/linux/mlx5/driver.h: In function ‘mlx5_get_vector_affinity_hint’:include/linux/mlx5/driver.h:1299:13: error:
‘struct irq_desc’ has no member named ‘affinity_hint’Note that this is the only use of
affinity_hintoutside kernel/irq. Don't other drivers have similar problems ?Aside of that.
Quoted 15 lines
Quoted 15 lines
static inline const struct cpumask *
(quoted diff) +2
-3-mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector) +mlx5_get_vector_affinity_hint(struct mlx5_core_dev *dev, int vector) { - const struct cpumask *mask; struct irq_desc *desc; unsigned int irq; int eqn; int err; - err = mlx5_vector2eqn(dev, MLX5_EQ_VEC_COMP_BASE + vector, &eqn, &irq); + err = mlx5_vector2eqn(dev, vector, &eqn, &irq); if (err) return NULL;
Quoted 11 lines
Quoted 8 lines
Review
Quoted 8 lines
(quoted diff) +1
-6desc = irq_to_desc(irq); -#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK - mask = irq_data_get_effective_affinity_mask(&desc->irq_data); -#else - mask = desc->irq_common_data.affinity; -#endif - return mask; + return desc->affinity_hint;NAK.
The offending patch is upstream, breaking non-SMP test builds, and I have not seen any feedback from the submitter. Any suggestion how to proceed ?
Guenter
Quoted 12 lines
Nothing in regular device drivers is supposed to ever fiddle with struct
irq_desc. The existing code is already a violation of that rule and needs to be fixed, but not in that way.The logic here is completely screwed.
affinity_hintis set by the driver, so the driver already knows what it is. If the driver does not set it, then the thing is NULL.Thanks,
tglx
Quoted 65 lines · Guenter Roeck
Quoted 54 lines · Thomas Gleixner
Quoted 20 lines · Guenter Roeck
Quoted 8 lines · Israel Rukshin
Adding the vector offset when calling to
mlx5_vector2eqn()is wrong.
This is becausemlx5_vector2eqn()checks if EQ index is equal to vector number
and the fact that the internal completion vectors that mlx5 allocates
don't get an EQ index.Quoted 7 lines
The second problem here is that using
effective_affinity_maskgives the same
CPU for different vectors.
This leads to unmapped queues when calling it fromblk_mq_rdma_map_queues().
This doesn't happen when usingaffinity_hintmask.Except that
affinity_hintis only defined if SMP is enabled. Without:Quoted 8 lines
include/linux/mlx5/driver.h: In function ‘mlx5_get_vector_affinity_hint’:include/linux/mlx5/driver.h:1299:13: error:
‘struct irq_desc’ has no member named ‘affinity_hint’Note that this is the only use of
affinity_hintoutside kernel/irq.
Don't other drivers have similar problems ?Aside of that.
Quoted 21 lines
Quoted 21 lines
static inline const struct cpumask *
-mlx5_get_vector_affinity(structmlx5_core_dev*dev, int vector)
+mlx5_get_vector_affinity_hint(structmlx5_core_dev*dev, int vector)
{(quoted diff) +0
-2- const struct cpumask *mask; struct irq_desc *desc; unsigned int irq; int eqn; int err; - err = mlx5_vector2eqn(dev, MLX5_EQ_VEC_COMP_BASE +vector, &eqn, &irq);
(quoted diff) +1
-2+ err = mlx5_vector2eqn(dev, vector, &eqn, &irq); if (err) return NULL; desc = irq_to_desc(irq); -#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK - mask = irq_data_get_effective_affinity_mask(&desc-Quoted 9 lines
Quoted 6 lines
Review
Quoted 6 lines
Quoted 1 line
irq_data);(quoted diff) +1
-4-#else - mask = desc->irq_common_data.affinity; -#endif - return mask; + return desc->affinity_hint;NAK.
Quoted 9 lines
The offending patch is upstream, breaking non-SMP test builds, and I have
not seen any feedback from the submitter. Any suggestion how to proceed ?Guenter
Quoted 1 line
Hi Guenter and Thomas,
Max and Israel are handling this internally to find a solution that provides the needed functionality for rdma and addresses your comments.
Thanks,
Saeed.