From: Achiad Shochat <ach...@mellanox.com> Under heavy network traffic load we may be in NAPI poll mode for a long time, thus IRQ affinity changes do not affect NAPI as desired.
Now once in a NAPI poll session we check the channel IRQ affinity, if it points to a different CPU core than the current, stop polling and the following device interrupt will fix the NAPI affinity. Signed-off-by: Achiad Shochat <ach...@mellanox.com> Signed-off-by: Or Gerlitz <ogerl...@mellanox.com> --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 0983a20..3c5c900 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -406,6 +406,9 @@ struct mlx5e_channel { u8 num_tc; unsigned long flags; + /* data path - accessed per napi poll */ + struct irq_desc *irq_desc; + /* control */ struct mlx5e_priv *priv; int ix; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 0bab33c..bdbef9f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1004,6 +1004,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, goto err_close_sqs; netif_set_xps_queue(netdev, get_cpu_mask(c->cpu), ix); + c->irq_desc = irq_to_desc(c->rq.cq.mcq.irqn); *cp = c; return 0; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index 2c7cb67..99e29c9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c @@ -30,6 +30,7 @@ * SOFTWARE. */ +#include <linux/irq.h> #include "en.h" struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq) @@ -49,6 +50,15 @@ struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq) return cqe; } +static inline bool mlx5e_no_channel_affinity_change(struct mlx5e_channel *c) +{ + int current_cpu = smp_processor_id(); + struct irq_data *d = irq_desc_get_irq_data(c->irq_desc); + struct cpumask *aff = irq_data_get_affinity_mask(d); + + return cpumask_test_cpu(current_cpu, aff); +} + int mlx5e_napi_poll(struct napi_struct *napi, int budget) { struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, @@ -65,7 +75,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= mlx5e_post_rx_wqes(&c->rq); - if (busy) + if (busy && likely(mlx5e_no_channel_affinity_change(c))) return budget; napi_complete(napi); -- 2.3.7 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html