diff mbox series

[ovs-dev,RFC,17/26] dpif-netdev: Postpone flow offload item freeing

Message ID 0d3273743cc46e0705f7ccbc7b5d228ded0166dd.1607177117.git.grive@u256.net
State RFC
Headers show
Series [ovs-dev,RFC,01/26] netdev: Add flow API de-init function | expand

Commit Message

Gaetan Rivet Dec. 5, 2020, 2:22 p.m. UTC
Profiling the HW offload thread, the flow offload freeing takes
approximatively 25% of the time. Most of this time is spent waiting on
the futex used by the libc free(), as it triggers a syscall and
reschedule the thread.

Avoid the syscall and its expensive context switch. Batch the offload
messages freeing using the RCU.

Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 lib/dpif-netdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 6a3413b2e..ea9d66580 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2621,13 +2621,19 @@  dp_netdev_alloc_flow_offload(struct dp_netdev_pmd_thread *pmd,
 }
 
 static void
-dp_netdev_free_flow_offload(struct dp_offload_thread_item *offload)
+dp_netdev_flow_offload_free(struct dp_offload_thread_item *offload)
+{
+    free(offload->actions);
+    free(offload);
+}
+
+static void
+dp_netdev_flow_offload_unref(struct dp_offload_thread_item *offload)
 {
     dp_netdev_pmd_unref(offload->pmd);
     dp_netdev_flow_unref(offload->flow);
 
-    free(offload->actions);
-    free(offload);
+    ovsrcu_postpone(dp_netdev_flow_offload_free, offload);
 }
 
 static void
@@ -2788,7 +2794,8 @@  dp_netdev_flow_offload_main(void *data OVS_UNUSED)
         VLOG_DBG("%s to %s netdev flow "UUID_FMT,
                  ret == 0 ? "succeed" : "failed", op,
                  UUID_ARGS((struct uuid *) &offload->flow->mega_ufid));
-        dp_netdev_free_flow_offload(offload);
+
+        dp_netdev_flow_offload_unref(offload);
 
         /* Do RCU synchronization at fixed interval. */
         if (now > next_rcu) {