RE: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf
> Of Jason Xing
> Sent: Tuesday, July 22, 2025 3:51 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@xxxxxxxxx>; andrew+netdev@xxxxxxx;
> davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx;
> pabeni@xxxxxxxxxx; bjorn@xxxxxxxxxx; Karlsson, Magnus
> <magnus.karlsson@xxxxxxxxx>; Fijalkowski, Maciej
> <maciej.fijalkowski@xxxxxxxxx>; jonathan.lemon@xxxxxxxxx;
> sdf@xxxxxxxxxxx; ast@xxxxxxxxxx; daniel@xxxxxxxxxxxxx;
> hawk@xxxxxxxxxx; john.fastabend@xxxxxxxxx; mcoquelin.stm32@xxxxxxxxx;
> alexandre.torgue@xxxxxxxxxxx
> Cc: linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx; bpf@xxxxxxxxxxxxxxx;
> intel-wired-lan@xxxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; Jason Xing
> <kernelxing@xxxxxxxxxxx>
> Subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix
> underflow of budget in zerocopy mode
> 
> From: Jason Xing <kernelxing@xxxxxxxxxxx>
> 
> An underflow can happen when the budget number of descs are consumed.
> as long as the budget is decreased to zero, it will again go into
> while (budget-- > 0) statement and get decreased by one, so the
> underflow issue can happen. It will lead to returning true whereas the
> expected value should be false.
> 
> In this case where all the budget is used up, it means zc function
> should return false to let the poll run again because normally we
> might have more data to process. Without this patch, zc function would
> return true instead.
> 
> Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")
> Signed-off-by: Jason Xing <kernelxing@xxxxxxxxxxx>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>
> ---
> v2
> Link: https://lore.kernel.org/all/20250721083343.16482-1-
> kerneljasonxing@xxxxxxxxx/
> 1. target net tree instead of net-next
> 2. revise commit message
> 3. use for loop to replace while loop
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f350a6662880..c4cd4526ba05 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct
> stmmac_priv *priv, u32 queue, u32 budget)
> 
>  	budget = min(budget, stmmac_tx_avail(priv, queue));
> 
> -	while (budget-- > 0) {
> +	for (; budget > 0; budget--)
>  		struct stmmac_metadata_request meta_req;
>  		struct xsk_tx_metadata *meta = NULL;
>  		dma_addr_t dma_addr;
> --
> 2.41.3






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux