]> git.droids-corp.org - dpdk.git/commit
ring: optimize corner case for enqueue/dequeue
authorAndrzej Ostruszka <amo@semihalf.com>
Tue, 11 Jan 2022 11:37:39 +0000 (12:37 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 4 Feb 2022 14:19:06 +0000 (15:19 +0100)
commit97ed4cb6fb324f4277ee754d4b6f3c7a0d96400b
tree775d0e88af2b033c9477bca6c005afbdf6c98a41
parent416c1bef9dbc9aed437f87e735500589d2e3d844
ring: optimize corner case for enqueue/dequeue

When enqueueing/dequeueing to/from the ring we try to optimize by manual
loop unrolling.  The check for this optimization looks like:

if (likely(idx + n < size)) {

where 'idx' points to the first usable element (empty slot for enqueue,
data for dequeue).  The correct comparison here should be '<=' instead
of '<'.

This is not a functional error since we fall back to the loop with
correct checks on indexes.  Just a minor suboptimal behaviour for the
case when we want to enqueue/dequeue exactly the number of elements that
we have in the ring before wrapping to its beginning.

Fixes: cc4b218790f6 ("ring: support configurable element size")
Fixes: 286bd05bf70d ("ring: optimisations")
Signed-off-by: Andrzej Ostruszka <amo@semihalf.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
lib/ring/rte_ring_elem_pvt.h