Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ring: optimize corner case for enqueue/dequeue
[ upstream commit 97ed4cb ] 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: cc4b218 ("ring: support configurable element size") Fixes: 286bd05 ("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>
- Loading branch information