[PATCH dpdk v2] ring: assert wraparound enqueue stays within input

Morten Brørup mb at smartsharesystems.com
Tue Dec 1 10:09:51 CET 2026


> From: Robin Jarry [mailto:rjarry at redhat.com]
> Sent: Tuesday, 1 December 2026 10.01
> 
> GCC 13 at -O2 reports -Wmaybe-uninitialized for a fully initialized
> 24-byte item passed to rte_ring_enqueue_elem(). The acquire fence
> introduced by commit f2f3cf6d098a ("ring: replace SMP barrier with
> acquire fence") exposes GCC's inability to infer that a valid wrap
> consumes fewer than n input words before restarting.
> 
> State that invariant with __rte_assume() inside the wrap loop instead
> of
> adding a condition to the loop.
> 
> Fixes: f2f3cf6d098a ("ring: replace SMP barrier with acquire fence")
> Cc: stable at dpdk.org
> Signed-off-by: Robin Jarry <rjarry at redhat.com>
> ---
> 
> Notes:
>     v2: replaced loop condition with __rte_assume()
> 
>  lib/ring/rte_ring_elem_pvt.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ring/rte_ring_elem_pvt.h
> b/lib/ring/rte_ring_elem_pvt.h
> index 3d680749ad96..77a2efafe119 100644
> --- a/lib/ring/rte_ring_elem_pvt.h
> +++ b/lib/ring/rte_ring_elem_pvt.h
> @@ -47,8 +47,10 @@ __rte_ring_enqueue_elems_32(void *ring_table, const
> void *obj_table,
>  			ring[idx++] = obj[i++]; /* fallthrough */
>  		}
>  	} else {
> -		for (i = 0; idx < size; i++, idx++)
> +		for (i = 0; idx < size; i++, idx++) {
> +			__rte_assume(i < n);
>  			ring[idx] = obj[i];
> +		}
>  		/* Start at the beginning */
>  		for (idx = 0; i < n; i++, idx++)
>  			ring[idx] = obj[i];
> --
> 2.56.1

Reviewed-by: Morten Brørup <mb at smartsharesystems.com>



More information about the stable mailing list