Skip to content

Commit 1aa621b

Browse files
dtatuleaBrian Maly
authored andcommitted
net/mlx5e: RX, Fix page_pool page fragment tracking for XDP
Currently mlx5e releases pages directly to the page_pool for XDP_TX and does page fragment counting for XDP_REDIRECT. RX pages from the page_pool are leaking on XDP_REDIRECT because the xdp core will release only one fragment out of MLX5E_PAGECNT_BIAS_MAX and subsequently the page is marked as "skip release" which avoids the driver release. A fix would be to take an extra fragment for XDP_REDIRECT and not set the "skip release" bit so that the release on the driver side can handle the remaining bias fragments. But this would be a shortsighted solution. Instead, this patch converges the two XDP paths (XDP_TX and XDP_REDIRECT) to always do fragment tracking. The "skip release" bit is no longer necessary for XDP. Fixes: 6f57428 ("net/mlx5e: RX, Enable skb page recycling through the page_pool") Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Orabug: 35622106 (cherry picked from commit 7abd955) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: 7abd955 Signed-off-by: Mikhael Goikhman <[email protected]> Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Devesh Sharma <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent efd89ff commit 1aa621b

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
662662
/* No need to check ((page->pp_magic & ~0x3UL) == PP_SIGNATURE)
663663
* as we know this is a page_pool page.
664664
*/
665-
page_pool_put_defragged_page(page->pp,
666-
page, -1, true);
665+
page_pool_recycle_direct(page->pp, page);
667666
} while (++n < num);
668667

669668
break;

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,11 +1771,11 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi
17711771

17721772
prog = rcu_dereference(rq->xdp_prog);
17731773
if (prog && mlx5e_xdp_handle(rq, prog, &mxbuf)) {
1774-
if (test_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1774+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
17751775
struct mlx5e_wqe_frag_info *pwi;
17761776

17771777
for (pwi = head_wi; pwi < wi; pwi++)
1778-
pwi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1778+
pwi->frag_page->frags++;
17791779
}
17801780
return NULL; /* page/packet was consumed by XDP */
17811781
}
@@ -1847,12 +1847,8 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
18471847
rq, wi, cqe, cqe_bcnt);
18481848
if (!skb) {
18491849
/* probably for XDP */
1850-
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1851-
/* do not return page to cache,
1852-
* it will be returned on XDP_TX completion.
1853-
*/
1854-
wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1855-
}
1850+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
1851+
wi->frag_page->frags++;
18561852
goto wq_cyc_pop;
18571853
}
18581854

@@ -1898,12 +1894,8 @@ static void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
18981894
rq, wi, cqe, cqe_bcnt);
18991895
if (!skb) {
19001896
/* probably for XDP */
1901-
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1902-
/* do not return page to cache,
1903-
* it will be returned on XDP_TX completion.
1904-
*/
1905-
wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1906-
}
1897+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
1898+
wi->frag_page->frags++;
19071899
goto wq_cyc_pop;
19081900
}
19091901

@@ -2082,12 +2074,12 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w
20822074
if (prog) {
20832075
if (mlx5e_xdp_handle(rq, prog, &mxbuf)) {
20842076
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
2085-
int i;
2077+
struct mlx5e_frag_page *pfp;
2078+
2079+
for (pfp = head_page; pfp < frag_page; pfp++)
2080+
pfp->frags++;
20862081

2087-
for (i = 0; i < sinfo->nr_frags; i++)
2088-
/* non-atomic */
2089-
__set_bit(page_idx + i, wi->skip_release_bitmap);
2090-
return NULL;
2082+
wi->linear_page.frags++;
20912083
}
20922084
mlx5e_page_release_fragmented(rq, &wi->linear_page);
20932085
return NULL; /* page/packet was consumed by XDP */
@@ -2185,7 +2177,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
21852177
cqe_bcnt, &mxbuf);
21862178
if (mlx5e_xdp_handle(rq, prog, &mxbuf)) {
21872179
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
2188-
__set_bit(page_idx, wi->skip_release_bitmap); /* non-atomic */
2180+
frag_page->frags++;
21892181
return NULL; /* page/packet was consumed by XDP */
21902182
}
21912183

0 commit comments

Comments
 (0)