[ovs-dev] [PATCH 1/1] netdev-afxdp: fix corner case where umem entries were not released

Eelco Chaudron echaudro at redhat.com
Thu Aug 8 13:27:05 UTC 2019


If for some reason the last element in the batch was already pushed on
the stack, none of the elements where pushed. This was leading to
buffer starvation.

Signed-off-by: Eelco Chaudron <echaudro at redhat.com>
---
 lib/netdev-afxdp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
index b7cc0d988..e5b058d08 100644
--- a/lib/netdev-afxdp.c
+++ b/lib/netdev-afxdp.c
@@ -811,15 +811,15 @@ afxdp_complete_tx(struct xsk_socket_info *xsk_info)
         void *elem;
 
         addr = (uint64_t *)xsk_ring_cons__comp_addr(&umem->cq, idx_cq++);
-        if (*addr == UINT64_MAX) {
+        if (*addr != UINT64_MAX) {
+            elem = ALIGNED_CAST(void *, (char *)umem->buffer + *addr);
+            elems_push[tx_to_free] = elem;
+            *addr = UINT64_MAX; /* Mark as pushed. */
+            tx_to_free++;
+        } else {
             /* The elem has been pushed already. */
             COVERAGE_INC(afxdp_cq_skip);
-            continue;
         }
-        elem = ALIGNED_CAST(void *, (char *)umem->buffer + *addr);
-        elems_push[tx_to_free] = elem;
-        *addr = UINT64_MAX; /* Mark as pushed. */
-        tx_to_free++;
 
         if (tx_to_free == BATCH_SIZE || j == tx_done - 1) {
             umem_elem_push_n(&umem->mpool, tx_to_free, elems_push);
-- 
2.18.1



More information about the dev mailing list