Re: [PATCH net-next] ptr_ring: __ptr_ring_zero_tail micro optimization
From: Simon Horman
Date: Mon Sep 29 2025 - 09:20:58 EST
On Sat, Sep 27, 2025 at 08:29:35AM -0400, Michael S. Tsirkin wrote:
> __ptr_ring_zero_tail currently does the - 1 operation twice:
> - during initialization of head
> - at each loop iteration
>
> Let's just do it in one place, all we need to do
> is adjust the loop condition. this is better:
> - a slightly clearer logic with less duplication
> - uses prefix -- we don't need to save the old value
> - one less - 1 operation - for example, when ring is empty
> we now don't do - 1 at all, existing code does it once
>
> Text size shrinks from 15081 to 15050 bytes.
>
> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>