Re: [PATCH V2 net 8/8] net/mlx5e: Preserve shared buffer capacity during headroom updates

Przemek Kitszel
2025-08-20T14:50:21Z

On 8/20/25 15:32, Mark Bloch wrote:
> From: Armen Ratner <armeng@nvidia.com>
>
> When port buffer headroom changes, port_update_shared_buffer()
> recalculates the shared buffer size and splits it in a 3:1 ratio
> (lossy:lossless) - Currently, the calculation is:
> lossless = shared / 4;
> lossy = (shared / 4) * 3;
>
> Meaning, the calculation dropped the remainder of shared % 4 due to
> integer division, unintentionally reducing the total shared buffer
> by up to three cells on each update. Over time, this could shrink
> the buffer below usable size.
>
> Fix it by changing the calculation to:
> lossless = shared / 4;
> lossy = shared - lossless;
>
> This retains all buffer cells while still approximating the
> intended 3:1 split, preventing capacity loss over time.

very nice fix and a good story :)
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

>
> While at it, perform headroom calculations in units of cells rather than
> in bytes for more accurate calculations avoiding extra divisions.

nit: next time I would split that into two commits