Re: [PATCH net-next v4] net: mana: Use page pool fragments for RX buffers instead of full pages to improve memory efficiency.
From: Dipayaan Roy <hidden>
Date: 2025-08-14 01:11:33
Also in:
bpf, linux-hyperv, linux-rdma, lkml
Hi Jakub, Thank you for the review comments, On Wed, Aug 13, 2025 at 04:48:47PM -0700, Jakub Kicinski wrote:
On Mon, 11 Aug 2025 15:29:19 -0700 Dipayaan Roy wrote:quoted
- if (apc->port_is_up) + if (apc->port_is_up) { + /* Re-create rxq's after xdp prog was loaded or unloaded. + * Ex: re create rxq's to switch from full pages to smaller + * size page fragments when xdp prog is unloaded and + * vice-versa. + */ + + /* Pre-allocate buffers to prevent failure in mana_attach */ + err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues); + if (err) { + NL_SET_ERR_MSG_MOD + (extack, + "XDP: Insufficient memory for tx/rx re-config");This weird line breaking is not necessary, checkpatch understands that string can go over line limit: NL_SET_ERR_MSG_MOD(extack, "XDP: Insufficient memory for tx/rx re-config");
Ok, I willl rectify this in v5.
quoted
+ return err;I think you already replaced the bpf program at this point? So the allocation should happen earlier. On failure changes to the driver state should be undone.
The bpf prog gets completely replaced in mana_chn_setxdp, I suggest these changes below to address your point on alloc failure and will work on a v5:
diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.cb/drivers/net/ethernet/microsoft/mana/mana_bpf.c index e616f4239294..0000c1dd7aa2 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c@@ -196,9 +196,6 @@ static int mana_xdp_set(struct net_device *ndev,struct bpf_prog *prog,
*/
apc->bpf_prog = prog;
- if (old_prog)
- bpf_prog_put(old_prog);
-
if (apc->port_is_up) {
/* Re-create rxq's after xdp prog was loaded or
* unloaded.
* Ex: re create rxq's to switch from full pages to
* smaller@@ -237,6 +234,9 @@ static int mana_xdp_set(struct net_device *ndev,struct bpf_prog *prog,
mana_pre_dealloc_rxbufs(apc);
}
+ if (old_prog)
+ bpf_prog_put(old_prog);
+
if (prog)
ndev->max_mtu = MANA_XDP_MTU_MAX;
else@@ -245,6 +245,7 @@ static int mana_xdp_set(struct net_device *ndev,struct bpf_prog *prog,
return 0;
err_dealloc_rxbuffs:
+ apc->bpf_prog = old_prog;
mana_pre_dealloc_rxbufs(apc);
return err;
}
-- pw-bot: cr
Thanks Dipayaan Roy