From: Dragos Tatulea In Striding RQ non-linear mode, there is a memcpy to pull the header from the first fragment into the linear part of the skb. As the header length is not aligned, it can cause cache thrashing from a Read-Modify-Write cycle for the remaining bytes of the cache line. This patch changes the memcopy length to be aligned to the cache line. The DMA sync is also aligned to cache line size accordingly. Note that the original DMA sync is done on the initial conservative headlen which is min(MLX5E_RX_MAX_HEAD, cqe_bcnt). To show the improvement, a test was run with an XDP_DROP program processing 64B packets at 100% CPU utilization over a single queue at 9000 MTU: |----------+----------+------| | Before | After | Diff | |----------+----------+------| | 3.6 Mpps | 3.8 Mpps | 5% | |----------+----------+------| (CX7 NIC on Intel Xeon Platinum 8580 system) While small packets profit most from this improvement, large packets are not negatively affected (no regressions). Suggested-by: Tariq Toukan Signed-off-by: Dragos Tatulea Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c index 301b33419207..e5963e1b5309 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -1973,7 +1973,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w addr = page_pool_get_dma_addr_netmem(head_page->netmem); dma_sync_single_for_cpu(rq->pdev, addr + head_offset, - ALIGN(headlen, sizeof(long)), + ALIGN(headlen, cache_line_size()), rq->buff.map_dir); headlen = eth_get_headlen(rq->netdev, head_addr, headlen); @@ -2086,7 +2086,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w /* copy header */ skb_copy_to_linear_data(skb, head_addr, - ALIGN(headlen, sizeof(long))); + ALIGN(headlen, cache_line_size())); /* skb linear part was allocated with headlen and aligned to long */ skb->tail += headlen; -- 2.44.0